knitr::opts_chunk$set(echo = TRUE)

rm(list = ls())

#cmdstanr::set_cmdstan_path(path = "C:/Users/kueng/.cmdstan/cmdstan-2.35.0")
#cmdstanr::set_cmdstan_path(path = "C:/Users/pascku/.cmdstan/cmdstan-2.36.0")

library(tidyverse)
library(R.utils)
library(wbCorr)
library(readxl)
library(kableExtra)
library(brms)
library(bayesplot)
library(see)
library(beepr)
library(DHARMa)
library(digest)
library(tidybayes)
library(ggplot2)



source(file.path('Functions', 'ReportModels.R'))
source(file.path('Functions', 'PrettyTables.R'))
source(file.path('Functions', 'ReportMeasures.R'))
source(file.path('Functions', 'PrepareData.R'))

report_function_hash <- digest::digest(summarize_brms)
system("shutdown /a")
## [1] 1116
# Set options for analysis
use_mi = FALSE
shutdown = FALSE
report_ordinal = FALSE
do_priorsense = FALSE
get_bayesfactor = TRUE
check_models = TRUE 

if (get_bayesfactor) {
  stats_to_report <- c('CI', 'SE', 'pd', 'ROPE', 'BF', 'Rhat', 'ESS')
} else {
  stats_to_report <- c('CI', 'SE', 'pd', 'ROPE', 'Rhat', 'ESS')
}

options(
  dplyr.print_max = 100, 
  brms.backend = 'cmdstan',
  brms.file_refit = ifelse(use_mi, 'never', 'on_change'),
  brms.file_refit = 'on_change',
  #brms.file_refit = 'always',
  error = function() {
    beepr::beep(sound = 5)
    if (shutdown) {
      system("shutdown /s /t 180")
      quit(save = "no", status = 1)
    }
  }
  , es.use_symbols = TRUE
)


####################### Model parameters #######################

iterations = 12000 # 12'000 per chain to achieve 40'000
warmup = 2000 # 2000

# NO AR!!!
#corstr = 'ar'
#corstr = 'cosy_couple'
#corstr = 'cosy_couple:user'


################################################################

suffix = paste0('_SensitivityBarriersFacilitatorsInteract_', as.character(iterations))
df <- openxlsx::read.xlsx(file.path('long.xlsx'))
df_original <- df

df_double <- prepare_data(df, recode_pushing = TRUE, use_mi = use_mi)[[1]]

Constructing scales Re-coding pusing reshaping data (4field) centering data within and between

summary(df_double$pushing)

Min. 1st Qu. Median Mean 3rd Qu. Max. NA’s 0.0000 0.0000 0.0000 0.1649 0.0000 5.0000 275

Modelling

# For indistinguishable Dyads
model_rows_fixed <- c(
    'Intercept', 
    # '-- WITHIN PERSON MAIN EFFECTS --', 
    'persuasion_self_cw', 
    'persuasion_partner_cw', 
    'pressure_self_cw', 
    'pressure_partner_cw', 
    'pushing_self_cw', 
    'pushing_partner_cw', 
    'day', 
    'plan_selfPlan',
    'plan_partnerPlan', # todo: do we need this??
    'barriers_self_cw', 
    'barriers_partner_cw',
    'facilitators_self_cw', 
    'facilitators_partner_cw',
    'weartime_self_cw',
    
    # '-- BETWEEN PERSON MAIN EFFECTS',
    'persuasion_self_cb',
    'persuasion_partner_cb',
    'pressure_self_cb',
    'pressure_partner_cb',
    'pushing_self_cb',
    'pushing_partner_cb',
    'barriers_self_cb', 
    'barriers_partner_cb',
    'facilitators_self_cb', 
    'facilitators_partner_cb',
    'weartime_self_cb',
    
    # Interactions
    'persuasion_self_cw:barriers_self_cw', 
    'barriers_self_cw:persuasion_self_cw',
    
    'pressure_self_cw:barriers_self_cw', 
    'barriers_self_cw:pressure_self_cw',
    
    'pushing_self_cw:barriers_self_cw', 
    'barriers_self_cw:pushing_self_cw', 
    
    'persuasion_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:persuasion_self_cw',
    
    'pressure_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:pressure_self_cw', 
    
    'pushing_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:pushing_self_cw', 
    
    'persuasion_partner_cw:barriers_self_cw', 
    'barriers_self_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:barriers_self_cw', 
    'barriers_self_cw:pressure_partner_cw', 
    
    'pushing_partner_cw:barriers_self_cw', 
    'barriers_self_cw:pushing_partner_cw', 
    
    'persuasion_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:pressure_partner_cw',
    
    'pushing_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:pushing_partner_cw', 
    
    'persuasion_self_cw:barriers_partner_cw', 
    'barriers_partner_cw:persuasion_self_cw', 
    
    'pressure_self_cw:barriers_partner_cw',
    'barriers_partner_cw:pressure_self_cw',
    
    'pushing_self_cw:barriers_partner_cw', 
    'barriers_partner_cw:pushing_self_cw', 
    
    'persuasion_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:persuasion_self_cw', 
    
    'pressure_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pressure_self_cw', 
    
    'pushing_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pushing_self_cw', 
    
    'persuasion_partner_cw:barriers_partner_cw',
    'barriers_partner_cw:persuasion_partner_cw',
    
    'pressure_partner_cw:barriers_partner_cw', 
    'barriers_partner_cw:pressure_partner_cw',
    
    'pushing_partner_cw:barriers_partner_cw', 
    'barriers_partner_cw:pushing_partner_cw', 
    
    'persuasion_partner_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pressure_partner_cw', 
    
    'pushing_partner_cw:facilitators_partner_cw',
    'facilitators_partner_cw:pushing_partner_cw'
  )


model_rows_fixed_ordinal <- c(
  model_rows_fixed[1],
  'Intercept[1]',
  'Intercept[2]',
  'Intercept[3]',
  'Intercept[4]',
  'Intercept[5]',
  model_rows_fixed[2:length(model_rows_fixed)]
)

model_rows_random <- c(
  # '--------------',
  # '-- RANDOM EFFECTS --',
  'sd(Intercept)', 
  'sd(persuasion_self_cw)',
  'sd(persuasion_partner_cw)',
  'sd(pressure_self_cw)',
  'sd(pressure_partner_cw)',
  'sd(pushing_self_cw)',
  'sd(pushing_partner_cw)',
  
  'sd(barriers_self_cw)', 
  'sd(barriers_partner_cw)',
  'sd(facilitators_self_cw)',
  'sd(facilitators_partner_cw)',
  
  # '-- CORRELATION STRUCTURE -- ', 
  'sigma'
)

model_rows_random_ordinal <- c(model_rows_random,'disc')
# For indistinguishable Dyads
model_rownames_fixed <- c(
    "Intercept", 
    # "-- WITHIN PERSON MAIN EFFECTS --", 
    "Daily individual's experienced persuasion",  
    "Daily partner's experienced persuasion", 
    "Daily individual's experienced pressure", 
    "Daily partner's experienced pressure", 
    "Daily individual's experienced pushing", 
    "Daily partner's experienced pushing", 
    "Day", 
    "Own action plan",
    'Partner action plan',
    "Daily individuals' barriers",
    "Daily partners' barriers",
    "Daily individuals' facilitators",
    "Daily partners' facilitators",
    "Daily wear time",
    

    # "-- BETWEEN PERSON MAIN EFFECTS",
    "Mean individual's experienced persuasion", 
    "Mean partner's experienced persuasion", 
    "Mean individual's experienced pressure", 
    "Mean partner's experienced pressure", 
    "Mean individual's experienced pushing", 
    "Mean partner's experienced pushing", 
    "Mean individuals' barriers",
    "Mean partners' barriers",
    "Mean individuals' facilitators",
    "Mean partners' facilitators",
    "Mean wear time",
    
    # Interactions
    'persuasion_self_cw:barriers_self_cw', 
    'barriers_self_cw:persuasion_self_cw',
    
    'pressure_self_cw:barriers_self_cw', 
    'barriers_self_cw:pressure_self_cw',
    
    'pushing_self_cw:barriers_self_cw', 
    'barriers_self_cw:pushing_self_cw', 
    
    'persuasion_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:persuasion_self_cw',
    
    'pressure_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:pressure_self_cw', 
    
    'pushing_self_cw:facilitators_self_cw', 
    'facilitators_self_cw:pushing_self_cw', 
    
    'persuasion_partner_cw:barriers_self_cw', 
    'barriers_self_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:barriers_self_cw', 
    'barriers_self_cw:pressure_partner_cw', 
    
    'pushing_partner_cw:barriers_self_cw', 
    'barriers_self_cw:pushing_partner_cw', 
    
    'persuasion_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:pressure_partner_cw',
    
    'pushing_partner_cw:facilitators_self_cw', 
    'facilitators_self_cw:pushing_partner_cw', 
    
    'persuasion_self_cw:barriers_partner_cw', 
    'barriers_partner_cw:persuasion_self_cw', 
    
    'pressure_self_cw:barriers_partner_cw',
    'barriers_partner_cw:pressure_self_cw',
    
    'pushing_self_cw:barriers_partner_cw', 
    'barriers_partner_cw:pushing_self_cw', 
    
    'persuasion_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:persuasion_self_cw', 
    
    'pressure_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pressure_self_cw', 
    
    'pushing_self_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pushing_self_cw', 
    
    'persuasion_partner_cw:barriers_partner_cw',
    'barriers_partner_cw:persuasion_partner_cw',
    
    'pressure_partner_cw:barriers_partner_cw', 
    'barriers_partner_cw:pressure_partner_cw',
    
    'pushing_partner_cw:barriers_partner_cw', 
    'barriers_partner_cw:pushing_partner_cw', 
    
    'persuasion_partner_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:persuasion_partner_cw', 
    
    'pressure_partner_cw:facilitators_partner_cw', 
    'facilitators_partner_cw:pressure_partner_cw', 
    
    'pushing_partner_cw:facilitators_partner_cw',
    'facilitators_partner_cw:pushing_partner_cw'
  )


model_rownames_fixed_ordinal <- c(
  model_rownames_fixed[1],
  'Intercept[1]',
  'Intercept[2]',
  'Intercept[3]',
  'Intercept[4]',
  'Intercept[5]',
  model_rownames_fixed[2:length(model_rownames_fixed)]
)

model_rownames_random <- c(
  # '--------------',
  # '-- RANDOM EFFECTS --',
  'sd(Intercept)', 
  "sd(Daily individual's experienced persuasion)", 
  "sd(Daily partner's experienced persuasion)", # OR partner received
  "sd(Daily individual's experienced pressure)", 
  "sd(Daily partner's experienced pressure)", 
  "sd(Daily individual's experienced pushing)", 
  "sd(Daily partner's experienced pushing)", 
  
  'sd(barriers_self_cw)', 
  'sd(barriers_partner_cw)', 
  'sd(barriers_partner_cw)',
  'sd(facilitators_self_cw)',
  'sd(facilitators_partner_cw)',
  # '-- CORRELATION STRUCTURE -- ', 
  'sigma'
)

model_rownames_random_ordinal <- c(model_rownames_random,'disc')
rows_to_pack <- list(
  "Within-Person Effects" = c(2,15),
  "Between-Person Effects" = c(16,26),
  "Interactions" = c(27, 74),
  "Random Effects" = c(75, 85), 
  "Additional Parameters" = c(86,86)
  )


rows_to_pack_ordinal <- list(
  "Within-Person Effects" = c(2+5,15+5),
  "Between-Person Effects" = c(16+5,26+5),
  "Interactions" = c(27+5, 74+5),
  "Random Effects" = c(75+5, 85+5), 
  "Additional Parameters" = c(86+5,86+6)
  )

Speficy interactions

interaction_terms <- paste(
    '+ persuasion_self_cw * barriers_self_cw',
    '+ pressure_self_cw * barriers_self_cw',
    '+ pushing_self_cw * barriers_self_cw',
      
    #'+ persuasion_self_cw * facilitators_self_cw',
    #'+ pressure_self_cw * facilitators_self_cw',
    #'+ pushing_self_cw * facilitators_self_cw',
    
    '+ persuasion_partner_cw * barriers_self_cw', 
    '+ pressure_partner_cw * barriers_self_cw', 
    '+ pushing_partner_cw * barriers_self_cw', 
    
    #'+ persuasion_partner_cw * facilitators_self_cw', 
    #'+ pressure_partner_cw * facilitators_self_cw', 
    #'+ pushing_partner_cw * facilitators_self_cw', 
    
    #'+ persuasion_self_cw * barriers_partner_cw', 
    #'+ pressure_self_cw * barriers_partner_cw',
    #'+ pushing_self_cw * barriers_partner_cw', 
    
    #'+ persuasion_self_cw * facilitators_partner_cw', 
    #'+ pressure_self_cw * facilitators_partner_cw', 
    #'+ pushing_self_cw * facilitators_partner_cw', 
    
    #'+ persuasion_partner_cw * barriers_partner_cw', 
    #'+ pressure_partner_cw * barriers_partner_cw', 
    #'+ pushing_partner_cw * barriers_partner_cw', 
  
    #'+ persuasion_partner_cw * facilitators_partner_cw', 
    #'+ pressure_partner_cw * facilitators_partner_cw',
    #'+ pushing_partner_cw * facilitators_partner_cw',
    ""
)


formula_terms <- paste(
  "~ 1",
  "+ persuasion_self_cw + persuasion_partner_cw",
  "+ pressure_self_cw + pressure_partner_cw",
  "+ pushing_self_cw + pushing_partner_cw",
  "+ persuasion_self_cb + persuasion_partner_cb",
  "+ pressure_self_cb + pressure_partner_cb",
  "+ pushing_self_cb + pushing_partner_cb",
  
  "+ barriers_self_cb + facilitators_self_cb",
  #"+ barriers_partner_cb + facilitators_partner_cb",
  "+ day",
  #"+ weartime_self_cw + weartime_self_cb", 
  interaction_terms,
  "+ (1",
  "+ persuasion_self_cw + persuasion_partner_cw",
  "+ pressure_self_cw + pressure_partner_cw",
  "+ pushing_self_cw + pushing_partner_cw",
  interaction_terms, 
  "| dd | coupleID)"
)

Self-Reported MVPA

range(df_double$pa_sub, na.rm = T) 
## [1]   0 720
hist(df_double$pa_sub, breaks = 40) 

hist(log(df_double$pa_sub+00000000001), breaks = 40)

Hurdle Lognormal Model

formula <- bf(
  as.formula(
    paste("pa_sub", formula_terms)
  ),
  
  hu = as.formula(
    formula_terms
  )

  , decomp = 'QR'
  #, autocor = autocor_str
) 

prior1 <- c(
  brms::set_prior("normal(0, 2.5)", class = "b")
  , brms::set_prior("normal(0, 2)", class = "b", dpar = "hu")
  , brms::set_prior("normal(0, 50)", class = "Intercept") # for non-zero PA
  , brms::set_prior("normal(0.5, 2.5)", class = "Intercept", dpar = 'hu') # hurdle part
  , brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0)
  , brms::set_prior("student_t(3, 0, 2.5)", class = "sigma", lb = 0)
)

#brms::validate_prior(
#  prior1, 
#  formula = formula, 
#  data = df_double, 
#  family = hurdle_lognormal()
#)

#df_minimal <- df_double[, c("AorB", all.vars(as.formula(formula)))]

pa_sub <- my_brm(
  mi = use_mi, 
  imputed_data = implist,
  
  formula = formula, 
  prior = prior1,
  data = df_double, 
  family = brms::hurdle_lognormal(), 
  #family = brms::hurdle_negbinomial(), 
  #family = brms::hurdle_poisson(),
  #control = list(adapt_delta = 0.90),
  iter = iterations,
  warmup = warmup,
  chains = 4,
  cores = 4,
  seed = 42,
  file = file.path("models_cache_brms", paste0("pa_sub_hu_lognormal", suffix))
  #, file_refit = 'always'
)
## Warning: Rows containing NAs were excluded from the model.
## Start sampling
pa_sub_digest <- digest::digest(pa_sub)
if (check_models) {
  check_brms(pa_sub, log_pp_check = TRUE)
  DHARMa.check_brms.all(pa_sub, integer = TRUE, outliers_type = 'bootstrap')
}
## # Check for Multicollinearity
## 
## Low Correlation
## 
##                   Term  VIF   VIF 95% CI Increased SE Tolerance
##     persuasion_self_cw 1.31 [1.30, 1.32]         1.14      0.76
##  persuasion_partner_cw 1.09 [1.08, 1.10]         1.04      0.92
##       pressure_self_cw 1.08 [1.08, 1.09]         1.04      0.92
##    pressure_partner_cw 1.06 [1.05, 1.07]         1.03      0.94
##        pushing_self_cw 1.06 [1.05, 1.07]         1.03      0.94
##     pushing_partner_cw 1.10 [1.09, 1.11]         1.05      0.91
##     persuasion_self_cb 1.06 [1.05, 1.07]         1.03      0.94
##  persuasion_partner_cb 3.91 [3.86, 3.95]         1.98      0.26
##       pressure_self_cb 3.83 [3.79, 3.88]         1.96      0.26
##    pressure_partner_cb 2.30 [2.28, 2.33]         1.52      0.43
##        pushing_self_cb 2.24 [2.22, 2.27]         1.50      0.45
##     pushing_partner_cb 3.13 [3.09, 3.17]         1.77      0.32
##       barriers_self_cb 3.14 [3.10, 3.17]         1.77      0.32
##   facilitators_self_cb 1.10 [1.09, 1.11]         1.05      0.91
##                    day 1.09 [1.08, 1.10]         1.04      0.92
##       barriers_self_cw 1.27 [1.26, 1.28]         1.13      0.79
##  Tolerance 95% CI
##      [0.76, 0.77]
##      [0.91, 0.92]
##      [0.92, 0.93]
##      [0.93, 0.95]
##      [0.94, 0.95]
##      [0.90, 0.91]
##      [0.94, 0.95]
##      [0.25, 0.26]
##      [0.26, 0.26]
##      [0.43, 0.44]
##      [0.44, 0.45]
##      [0.32, 0.32]
##      [0.32, 0.32]
##      [0.90, 0.91]
##      [0.91, 0.93]
##      [0.78, 0.80]
## # Distribution of Model Family
## 
## Predicted Distribution of Residuals
## 
##  Distribution Probability
##        cauchy         91%
##     lognormal          9%
## 
## Predicted Distribution of Response
## 
##                Distribution Probability
##  neg. binomial (zero-infl.)         84%
##               beta-binomial          9%
##                   lognormal          6%
## 
## Divergences:
## 0 of 40000 iterations ended with a divergence.
## 
## Tree depth:
## 0 of 40000 iterations saturated the maximum tree depth of 10.
## 
## Energy:
## E-BFMI indicated no pathological behavior.

## Using 10 posterior draws for ppc type 'ecdf_overlay' by default.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

## Warning: Found 31 observations with a pareto_k > 0.7 in model 'model'.
## We recommend to set 'moment_match = TRUE' in order to perform moment
## matching for problematic observations.

## 
##  DHARMa bootstrapped outlier test
## 
## data:  model.check
## outliers at both margin(s) = 5, observations = 1776, p-value =
## 0.4
## alternative hypothesis: two.sided
##  percent confidence interval:
##  0.00000000 0.00423705
## sample estimates:
## outlier frequency (expected: 0.00170045045045045 ) 
##                                        0.002815315
if (do_priorsense) {
  priorsense_vars <- c(
      'Intercept',
      'b_persuasion_self_cw',
      'b_persuasion_partner_cw',
      'b_pressure_self_cw',
      'b_pressure_partner_cw',
      'b_pushing_self_cw',
      'b_pushing_partner_cw'
  )
  
  hurdle_priorsense_vars <- c(
    'Intercept_hu',
    'b_hu_persuasion_self_cw',
    'b_hu_persuasion_partner_cw',
    'b_hu_pressure_self_cw',
    'b_hu_pressure_partner_cw',
    'b_hu_pushing_self_cw',
    'b_hu_pushing_partner_cw'
  )
  
  gc()
  priorsense::powerscale_sensitivity(pa_sub, variable = c(priorsense_vars, hurdle_priorsense_vars))
  priorsense::powerscale_plot_dens(pa_sub, variable = c(priorsense_vars, hurdle_priorsense_vars))
  priorsense::powerscale_plot_ecdf(pa_sub, variable = c(priorsense_vars, hurdle_priorsense_vars))
  priorsense::powerscale_plot_quantities(pa_sub, variable = c(priorsense_vars, hurdle_priorsense_vars))
}
# rope range for continuous part of the model
rope_factor <- sd(log(pa_sub$data$pa_sub[pa_sub$data$pa_sub > 0]))
rope_range_continuous = c(-0.1 * rope_factor, 0.1 * rope_factor)

summary_pa_sub <- summarize_brms(
  pa_sub, 
  stats_to_report = stats_to_report,
  rope_range = rope_range_continuous,
  hu_rope_range = c(-0.18, 0.18),
  model_rows_fixed = model_rows_fixed,
  model_rows_random = model_rows_random,
  model_rownames_fixed = model_rownames_fixed,
  model_rownames_random = model_rownames_random,
  exponentiate = T) 
## Sampling priors, please wait...
## Warning in summarize_brms(pa_sub, stats_to_report = stats_to_report,
## rope_range = rope_range_continuous, : Coefficients were exponentiated.
## Double check if this was intended.
## Warning in summarize_brms(pa_sub, stats_to_report = stats_to_report,
## rope_range = rope_range_continuous, : Some rows from the model were
## omitted due to your provided model_rows_fixed or model_rows_random
## vectors. Missing rows: sd(persuasion_partner_cw:barriers_self_cw),
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw)
## Warning in summarize_brms(pa_sub, stats_to_report = stats_to_report,
## rope_range = rope_range_continuous, : Length of model_rownames does not
## match number of rows
# Print the updated dataframe
summary_pa_sub %>%
  print_df(
    rows_to_pack = rows_to_pack
    )
exp(Est.)_hu SE_hu 95% CI_hu pd_hu ROPE_hu inside ROPE_hu BF_hu BF_Evidence_hu Rhat_hu Bulk_ESS_hu Tail_ESS_hu exp(Est.)_nonzero SE_nonzero 95% CI_nonzero pd_nonzero ROPE_nonzero inside ROPE_nonzero BF_nonzero BF_Evidence_nonzero Rhat_nonzero Bulk_ESS_nonzero Tail_ESS_nonzero
Intercept 2.89*** 0.83 [ 1.62, 5.14] 1.000 [0.84, 1.20] 0.002 46.729 Very Strong Evidence 1.000 36107 32627 49.15*** 4.02 [41.78, 58.06] 1.000 [0.93, 1.08] 0.000 >100 Overwhelming Evidence 1.000 14059 20647
Within-Person Effects
persuasion_self_cw 1.61*** 0.19 [ 1.30, 2.07] 1.000 [0.84, 1.20] 0.003 >100 Overwhelming Evidence 1.000 47652 31218 1.04 0.03 [ 0.99, 1.10] 0.928 [0.93, 1.08] 0.904 0.029 Very Strong Evidence for Null 1.000 32436 32732
persuasion_partner_cw 1.44*** 0.16 [ 1.17, 1.86] 1.000 [0.84, 1.20] 0.041 18.216 Strong Evidence 1.000 44125 31400 1.02 0.02 [ 0.98, 1.07] 0.811 [0.93, 1.08] 0.988 0.013 Very Strong Evidence for Null 1.000 45651 33711
pressure_self_cw 0.84 0.28 [ 0.43, 1.92] 0.698 [0.84, 1.20] 0.356 0.198 Moderate Evidence for Null 1.000 36472 24492 0.90 0.06 [ 0.78, 1.03] 0.946 [0.93, 1.08] 0.305 0.041 Strong Evidence for Null 1.000 40255 31489
pressure_partner_cw 1.64 0.65 [ 0.85, 5.26] 0.923 [0.84, 1.20] 0.171 0.443 Weak Evidence for Null 1.000 27246 24271 0.96 0.05 [ 0.86, 1.06] 0.791 [0.93, 1.08] 0.756 0.012 Very Strong Evidence for Null 1.000 44440 34295
pushing_self_cw 1.22 0.23 [ 0.82, 1.84] 0.854 [0.84, 1.20] 0.428 0.176 Moderate Evidence for Null 1.000 39647 30278 0.98 0.03 [ 0.92, 1.05] 0.701 [0.93, 1.08] 0.950 0.011 Very Strong Evidence for Null 1.000 39607 37174
pushing_partner_cw 1.60* 0.36 [ 1.07, 2.78] 0.989 [0.84, 1.20] 0.077 1.609 Weak Evidence 1.000 34873 26963 0.96 0.03 [ 0.90, 1.02] 0.907 [0.93, 1.08] 0.854 0.021 Very Strong Evidence for Null 1.000 41168 36861
day 0.88 0.22 [ 0.54, 1.42] 0.702 [0.84, 1.20] 0.480 0.140 Moderate Evidence for Null 1.000 83049 31083 1.03 0.07 [ 0.89, 1.18] 0.647 [0.93, 1.08] 0.684 0.009 Very Strong Evidence for Null 1.000 73504 30624
plan_selfPlan NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_self_cw 0.68 0.17 [ 0.42, 1.12] 0.938 [0.84, 1.20] 0.185 0.432 Weak Evidence for Null 1.000 37413 32446 1.08 0.06 [ 0.97, 1.20] 0.930 [0.93, 1.08] 0.493 0.040 Strong Evidence for Null 1.000 36312 30151
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Between-Person Effects
persuasion_self_cb 0.91 0.57 [ 0.25, 3.09] 0.563 [0.84, 1.20] 0.226 0.319 Weak Evidence for Null 1.000 25393 28776 1.07 0.18 [ 0.76, 1.50] 0.651 [0.93, 1.08] 0.329 0.017 Very Strong Evidence for Null 1.000 23466 28917
persuasion_partner_cb 1.35 0.84 [ 0.38, 4.59] 0.684 [0.84, 1.20] 0.202 0.356 Weak Evidence for Null 1.000 25207 28535 0.94 0.16 [ 0.67, 1.31] 0.640 [0.93, 1.08] 0.335 0.017 Very Strong Evidence for Null 1.000 21992 29105
pressure_self_cb 0.23 0.20 [ 0.04, 1.24] 0.956 [0.84, 1.20] 0.040 1.874 Weak Evidence 1.000 36118 33182 0.69 0.28 [ 0.31, 1.59] 0.816 [0.93, 1.08] 0.100 0.037 Strong Evidence for Null 1.000 10355 16869
pressure_partner_cb 0.20 0.17 [ 0.03, 1.03] 0.972 [0.84, 1.20] 0.028 2.636 Weak Evidence 1.000 36552 33738 0.51 0.21 [ 0.23, 1.17] 0.946 [0.93, 1.08] 0.039 0.095 Strong Evidence for Null 1.000 10275 17210
pushing_self_cb 1.35 1.21 [ 0.23, 7.96] 0.632 [0.84, 1.20] 0.152 0.483 Weak Evidence for Null 1.000 33489 31707 1.50 0.45 [ 0.83, 2.70] 0.913 [0.93, 1.08] 0.079 0.043 Strong Evidence for Null 1.000 14333 21871
pushing_partner_cb 1.76 1.59 [ 0.30, 10.33] 0.732 [0.84, 1.20] 0.132 0.555 Weak Evidence for Null 1.000 34246 32112 1.65 0.50 [ 0.91, 2.95] 0.950 [0.93, 1.08] 0.052 0.067 Strong Evidence for Null 1.000 13692 23296
barriers_self_cb 0.50** 0.13 [ 0.30, 0.83] 0.997 [0.84, 1.20] 0.023 5.072 Moderate Evidence 1.000 86915 31419 0.92 0.08 [ 0.78, 1.09] 0.827 [0.93, 1.08] 0.452 0.016 Very Strong Evidence for Null 1.000 56891 32994
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 1.20 0.23 [ 0.82, 1.77] 0.831 [0.84, 1.20] 0.458 0.153 Moderate Evidence for Null 1.000 69399 31737 1.14* 0.06 [ 1.03, 1.27] 0.992 [0.93, 1.08] 0.151 0.258 Moderate Evidence for Null 1.000 38644 32619
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cb NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Interactions
persuasion_self_cw:barriers_self_cw 0.95 0.20 [ 0.62, 1.46] 0.599 [0.84, 1.20] 0.598 0.104 Moderate Evidence for Null 1.000 40097 30713 0.99 0.04 [ 0.92, 1.07] 0.570 [0.93, 1.08] 0.946 0.010 Very Strong Evidence for Null 1.000 46953 33280
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw 0.49 0.26 [ 0.15, 1.54] 0.906 [0.84, 1.20] 0.102 0.721 Weak Evidence for Null 1.000 40753 29719 1.02 0.12 [ 0.79, 1.31] 0.557 [0.93, 1.08] 0.469 0.012 Very Strong Evidence for Null 1.000 39661 31246
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 1.94 0.66 [ 0.99, 4.10] 0.973 [0.84, 1.20] 0.067 1.187 Weak Evidence 1.000 36948 31340 0.96 0.05 [ 0.86, 1.07] 0.777 [0.93, 1.08] 0.716 0.014 Very Strong Evidence for Null 1.000 39441 33259
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 0.68* 0.12 [ 0.46, 0.95] 0.989 [0.84, 1.20] 0.110 1.212 Weak Evidence 1.000 42700 32366 1.06 0.04 [ 0.99, 1.13] 0.946 [0.93, 1.08] 0.709 0.033 Strong Evidence for Null 1.000 57612 34728
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw 0.82 0.44 [ 0.26, 2.53] 0.647 [0.84, 1.20] 0.245 0.281 Moderate Evidence for Null 1.000 43577 31306 0.90 0.07 [ 0.75, 1.05] 0.916 [0.93, 1.08] 0.323 0.025 Very Strong Evidence for Null 1.000 42764 30340
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 1.71 0.51 [ 0.99, 3.43] 0.974 [0.84, 1.20] 0.097 0.920 Weak Evidence for Null 1.000 35042 30469 1.05 0.05 [ 0.95, 1.18] 0.851 [0.93, 1.08] 0.669 0.016 Very Strong Evidence for Null 1.000 45960 32440
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 1.44 0.22 [1.08, 1.97] NA NA NA NA NA 1.000 27830 30182 0.31 0.05 [0.23, 0.42] NA NA NA NA NA 1.000 18714 26238
sd(persuasion_self_cw) 0.17 0.14 [0.01, 0.51] NA NA NA NA NA 1.000 19021 21922 0.10 0.03 [0.05, 0.16] NA NA NA NA NA 1.000 15886 16147
sd(persuasion_partner_cw) 0.20 0.15 [0.01, 0.54] NA NA NA NA NA 1.000 16993 21418 0.05 0.03 [0.01, 0.11] NA NA NA NA NA 1.000 14162 13842
sd(pressure_self_cw) 0.54 0.48 [0.03, 2.05] NA NA NA NA NA 1.000 17469 24791 0.08 0.07 [0.00, 0.30] NA NA NA NA NA 1.000 19070 23257
sd(pressure_partner_cw) 0.53 0.48 [0.03, 2.08] NA NA NA NA NA 1.000 18042 23934 0.05 0.05 [0.00, 0.20] NA NA NA NA NA 1.000 24798 22570
sd(pushing_self_cw) 0.61 0.30 [0.07, 1.30] NA NA NA NA NA 1.000 12779 12795 0.07 0.04 [0.00, 0.16] NA NA NA NA NA 1.000 15015 19267
sd(pushing_partner_cw) 0.64 0.34 [0.07, 1.47] NA NA NA NA NA 1.000 13111 14791 0.06 0.04 [0.00, 0.15] NA NA NA NA NA 1.000 16130 16326
sd(barriers_self_cw) 1.27 0.22 [0.91, 1.79] NA NA NA NA NA 1.000 35412 33128 0.20 0.06 [0.08, 0.33] NA NA NA NA NA 1.000 13833 12632
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma NA NA NA NA NA NA NA NA NA NA NA 0.66 0.01 [0.63, 0.69] NA NA NA NA NA 1.000 45048 31583
# Plot continuous part of model

variable <- c(
  '(Intercept)',
  'b_persuasion_self_cw',
  'b_persuasion_partner_cw',
  'b_pressure_self_cw',
  'b_pressure_partner_cw',
  'b_pushing_self_cw',
  'b_pushing_partner_cw'
)


plot(
  bayestestR::p_direction(pa_sub, parameter = variable),
  priors = TRUE
) + theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple
## of shorter object length

plot(
  bayestestR::rope(
    pa_sub, 
    parameter = variable, 
    range = rope_range_continuous,
    verbose = F,
    ci = 1
  )
) + theme_bw()

# Hurdle part of the model
variable <- c(
  'b_hu_persuasion_self_cw',
  'b_hu_persuasion_partner_cw',
  'b_hu_pressure_self_cw',
  'b_hu_pressure_partner_cw',
  'b_hu_pushing_self_cw',
  'b_hu_pushing_partner_cw'
)

plot(
  bayestestR::p_direction(pa_sub, parameter = variable),
  priors = TRUE
) + theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length

# The rope range for the bernoulli part of the model is -0.18, 0.18
plot(
  bayestestR::rope(pa_sub, parameter = variable, range = c(-0.18, 0.18), ci = 1),
  verbose = FALSE
) + theme_bw()
## Possible multicollinearity between b_hu_persuasion_partner_cb and
##   b_hu_persuasion_self_cb (r = 0.78), b_persuasion_partner_cb and
##   b_persuasion_self_cb (r = 0.73), b_pressure_partner_cb and
##   b_pressure_self_cb (r = 0.81). This might lead to inappropriate
##   results. See 'Details' in '?rope'.

Hurdle part of the model on the left, non-zero part towards the right side of the table

conds_eff <- conditional_spaghetti(
  pa_sub, 
  effects = c(
    'persuasion_self_cw',
    'persuasion_partner_cw',
    'pressure_self_cw',
    'pressure_partner_cw',
    'pushing_self_cw',
    'pushing_partner_cw'
  ),
  x_label = c(
    'Received Persuasion',
    'Exerted Persuasion',
    'Received Pressure',
    'Exerted Pressure',
    'Received Plan-Related Pushing',
    'Exerted Plan-Related Pushing'
  ),
  group_var = 'coupleID',
  plot_full_range = TRUE,
  y_limits = c(0, 100),
  y_label = "Same-Day MVPA",
  y_labels = c('Probability of Being Active', 'Minutes of MVPA When Active', 'Overall Expected Minutes of MVPA'),
  , filter_quantiles = .9995
  , font_family = 'Candara'
)
## Scanning ttf files in C:\Windows/Fonts, C:\Users\pascku\AppData\Local/Microsoft/Windows/Fonts ...
## Extracting .afm files from .ttf files...
## C:\Windows\Fonts\Candara.ttf : Candara already registered in fonts database. Skipping.
## C:\Windows\Fonts\Candarab.ttf : Candara-Bold already registered in fonts database. Skipping.
## C:\Windows\Fonts\Candarai.ttf : Candara-Italic already registered in fonts database. Skipping.
## C:\Windows\Fonts\Candaral.ttf : Candara-Light already registered in fonts database. Skipping.
## C:\Windows\Fonts\Candarali.ttf : Candara-LightItalic already registered in fonts database. Skipping.
## C:\Windows\Fonts\Candaraz.ttf : Candara-BoldItalic already registered in fonts database. Skipping.
## Found FontName for 0 fonts.
## Scanning afm files in C:/Users/pascku/AppData/Local/R/cache/R/renv/cache/v5/windows/R-4.4/x86_64-w64-mingw32/extrafontdb/1.0/a861555ddec7451c653b40e713166c6f/extrafontdb/metrics
## Warning: Dropping 'draws_df' class as required metadata was removed.
## Warning: Dropping 'draws_df' class as required metadata was removed.
## Warning: Dropping 'draws_df' class as required metadata was removed.
## Warning: Dropping 'draws_df' class as required metadata was removed.
## Warning: Dropping 'draws_df' class as required metadata was removed.
## Warning: Dropping 'draws_df' class as required metadata was removed.
print(conds_eff)

$persuasion_self_cw

## Warning: Removed 105 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Warning: Removed 211 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.00958

$persuasion_partner_cw

## Warning: Removed 77 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Warning: Removed 174 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.00839

$pressure_self_cw

## Warning: Removed 45 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Warning: Removed 89 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.0159

$pressure_partner_cw

## Warning: Removed 25 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.0303

$pushing_self_cw

## Warning: Removed 13 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Warning: Removed 35 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.0116

$pushing_partner_cw

## Warning: Removed 16 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Warning: Removed 43 rows containing missing values or values outside the scale
## range (`geom_line()`).
## Picking joint bandwidth of 0.0166

Note. This graphic illustrates the relationship between social control and moderate to vigorous physical activity (MVPA) using a Bayesian Hurdle-Lognormal Multilevel Model. The predictor is centered within individuals to examine how deviations from their average social control relate to same-day MVPA. Shaded areas indicate credible intervals, thick lines show fixed effects, and thin lines represent random effects, highlighting variability across couples. The plots display the probability of being active, expected minutes of MVPA when active, and combined predicted MVPA. The bottom density plot visualizes the posterior distributions of slope estimates, transformed to represent multiplicative changes in odds ratios (hurdle component) or expected values. Medians and 95% credible intervals (2.5th and 97.5th percentiles) are shown. Effects are significant, when the 95% credible interval does not overlap 1.

Comparing effect size of pressure and pushing

hypothesis(pa_sub, "pressure_self_cw < pushing_self_cw")
## Hypothesis Tests for class b:
##                 Hypothesis Estimate Est.Error CI.Lower CI.Upper
## 1 (pressure_self_cw... < 0    -0.09      0.08    -0.23     0.04
##   Evid.Ratio Post.Prob Star
## 1       6.62      0.87     
## ---
## 'CI': 90%-CI for one-sided and 95%-CI for two-sided hypotheses.
## '*': For one-sided hypotheses, the posterior probability exceeds 95%;
## for two-sided hypotheses, the value tested against lies outside the 95%-CI.
## Posterior probabilities of point hypotheses assume equal prior probabilities.

Device Based MVPA

range(df_double$pa_obj, na.rm = T) 
## [1]   5.75 971.25
hist(df_double$pa_obj, breaks = 50)

df_double$pa_obj_log <- log(df_double$pa_obj)

hist(df_double$pa_obj_log, breaks = 50)

Lognormal Model

formula <- bf(
  as.formula(
    paste("pa_obj", formula_terms, "+ weartime_self_cw + weartime_self_cb")
  )
  
  , decomp = 'QR'
  #, autocor = autocor_str
)


prior1 <- c(
  brms::set_prior("normal(0, 2.5)", class = "b")
  , brms::set_prior("normal(0, 50)", class = "Intercept") 
  , brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0)
  , brms::set_prior("student_t(3, 0, 2.5)", class = "sigma", lb = 0)
)


#brms::validate_prior(
#  prior1, 
#  formula = formula, 
#  data = df_double, 
#  family = lognormal()
#  )

#df_minimal <- df_double[, c("AorB", all.vars(as.formula(formula)))]

pa_obj_log <- my_brm(
  mi = use_mi, 
  imputed_data = implist,
  
  formula = formula, 
  prior = prior1,
  data = df_double, 
  family = lognormal(),
  control = list(adapt_delta = 0.99),
  iter = iterations + 200,
  warmup = warmup + 200,
  chains = 4,
  cores = 4,
  seed = 7777,
  file = file.path("models_cache_brms", paste0("pa_obj_log_gaussian", suffix))
  #, file_refit = 'always'
)
## Warning: Rows containing NAs were excluded from the model.
pa_obj_log_digest <- digest::digest(pa_obj_log)
if (check_models) {
  check_brms(pa_obj_log, log_pp_check = TRUE)
  DHARMa.check_brms.all(pa_obj_log, integer = TRUE, outliers_type = 'bootstrap')
}
## # Check for Multicollinearity
## 
## Low Correlation
## 
##                   Term  VIF   VIF 95% CI Increased SE Tolerance
##     persuasion_self_cw 1.12 [1.09, 1.16]         1.06      0.89
##  persuasion_partner_cw 1.14 [1.11, 1.18]         1.07      0.88
##       pressure_self_cw 1.09 [1.06, 1.13]         1.04      0.92
##    pressure_partner_cw 1.12 [1.09, 1.16]         1.06      0.89
##        pushing_self_cw 1.20 [1.16, 1.24]         1.09      0.83
##     pushing_partner_cw 1.20 [1.17, 1.25]         1.10      0.83
##       pressure_self_cb 3.66 [3.49, 3.85]         1.91      0.27
##    pressure_partner_cb 3.80 [3.62, 4.00]         1.95      0.26
##       barriers_self_cb 1.12 [1.09, 1.16]         1.06      0.89
##   facilitators_self_cb 1.12 [1.09, 1.16]         1.06      0.89
##                    day 1.06 [1.04, 1.10]         1.03      0.94
##       barriers_self_cw 1.05 [1.02, 1.09]         1.02      0.95
##       weartime_self_cw 1.06 [1.04, 1.10]         1.03      0.94
##       weartime_self_cb 1.23 [1.19, 1.28]         1.11      0.81
##  Tolerance 95% CI
##      [0.86, 0.92]
##      [0.85, 0.90]
##      [0.88, 0.94]
##      [0.86, 0.92]
##      [0.80, 0.86]
##      [0.80, 0.86]
##      [0.26, 0.29]
##      [0.25, 0.28]
##      [0.86, 0.92]
##      [0.86, 0.92]
##      [0.91, 0.97]
##      [0.92, 0.98]
##      [0.91, 0.97]
##      [0.78, 0.84]
## 
## Moderate Correlation
## 
##                   Term  VIF   VIF 95% CI Increased SE Tolerance
##     persuasion_self_cb 6.95 [6.59, 7.33]         2.64      0.14
##  persuasion_partner_cb 7.39 [7.01, 7.80]         2.72      0.14
##        pushing_self_cb 5.59 [5.30, 5.89]         2.36      0.18
##     pushing_partner_cb 5.45 [5.18, 5.74]         2.33      0.18
##  Tolerance 95% CI
##      [0.14, 0.15]
##      [0.13, 0.14]
##      [0.17, 0.19]
##      [0.17, 0.19]
## # Distribution of Model Family
## 
## Predicted Distribution of Residuals
## 
##  Distribution Probability
##        cauchy         88%
##     lognormal          9%
##       weibull          3%
## 
## Predicted Distribution of Response
## 
##                Distribution Probability
##                   lognormal         72%
##                     tweedie         16%
##  neg. binomial (zero-infl.)          9%
## 
## Divergences:
## 0 of 40000 iterations ended with a divergence.
## 
## Tree depth:
## 0 of 40000 iterations saturated the maximum tree depth of 10.
## 
## Energy:
## E-BFMI indicated no pathological behavior.

## Using 10 posterior draws for ppc type 'ecdf_overlay' by default.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

## Warning: Found 2 observations with a pareto_k > 0.7 in model 'model'. We
## recommend to set 'moment_match = TRUE' in order to perform moment
## matching for problematic observations.
## DHARMa:testOutliers with type = binomial may have inflated Type I error rates for integer-valued distributions. To get a more exact result, it is recommended to re-run testOutliers with type = 'bootstrap'. See ?testOutliers for details

## 
##  DHARMa bootstrapped outlier test
## 
## data:  model.check
## outliers at both margin(s) = 11, observations = 1594, p-value =
## 0.02
## alternative hypothesis: two.sided
##  percent confidence interval:
##  0.000925345 0.006273526
## sample estimates:
## outlier frequency (expected: 0.00310539523212045 ) 
##                                        0.006900878
if (do_priorsense) {
  gc()
  priorsense::powerscale_sensitivity(pa_obj_log, variable = priorsense_vars)
  priorsense::powerscale_plot_dens(pa_obj_log, variable = priorsense_vars)
  priorsense::powerscale_plot_ecdf(pa_obj_log, variable = priorsense_vars)
  priorsense::powerscale_plot_quantities(pa_obj_log, variable = priorsense_vars)
}
# rope range for lognormal model
rope_factor <- sd(log(pa_obj_log$data$pa_obj))
rope_range_log = c(-0.1 * rope_factor, 0.1 * rope_factor)

summary_pa_obj <- summarize_brms(
  pa_obj_log, 
  stats_to_report = stats_to_report,
  rope_range = rope_range_log,
  model_rows_fixed = model_rows_fixed,
  model_rows_random = model_rows_random,
  model_rownames_fixed = model_rownames_fixed,
  model_rownames_random = model_rownames_random,
  exponentiate = T) 
## Sampling priors, please wait...
## Warning in summarize_brms(pa_obj_log, stats_to_report = stats_to_report,
## : Coefficients were exponentiated. Double check if this was intended.
## Warning in summarize_brms(pa_obj_log, stats_to_report = stats_to_report,
## : Some rows from the model were omitted due to your provided
## model_rows_fixed or model_rows_random vectors. Missing rows:
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(pa_obj_log, stats_to_report = stats_to_report,
## : Length of model_rownames does not match number of rows
summary_pa_obj %>%
  print_df(
    rows_to_pack = rows_to_pack
    )
exp(Est.) SE 95% CI pd ROPE inside ROPE BF BF_Evidence Rhat Bulk_ESS Tail_ESS
Intercept 122.92*** 7.50 [108.77, 138.83] 1.000 [0.94, 1.06] 0.000 >100 Overwhelming Evidence 1.002 6870 14120
Within-Person Effects
persuasion_self_cw 1.03 0.02 [ 0.99, 1.06] 0.908 [0.94, 1.06] 0.974 0.018 Very Strong Evidence for Null 1.000 23617 27233
persuasion_partner_cw 1.03 0.02 [ 0.99, 1.07] 0.950 [0.94, 1.06] 0.952 0.028 Very Strong Evidence for Null 1.000 27240 26910
pressure_self_cw 0.95 0.05 [ 0.85, 1.05] 0.848 [0.94, 1.06] 0.563 0.013 Very Strong Evidence for Null 1.000 28839 25172
pressure_partner_cw 0.98 0.04 [ 0.90, 1.06] 0.726 [0.94, 1.06] 0.820 0.008 Very Strong Evidence for Null 1.000 35044 28996
pushing_self_cw 1.03 0.03 [ 0.97, 1.08] 0.822 [0.94, 1.06] 0.902 0.012 Very Strong Evidence for Null 1.000 30297 26694
pushing_partner_cw 0.99 0.02 [ 0.94, 1.04] 0.655 [0.94, 1.06] 0.980 0.007 Very Strong Evidence for Null 1.000 34670 27675
day 0.97 0.05 [ 0.88, 1.07] 0.725 [0.94, 1.06] 0.711 0.007 Very Strong Evidence for Null 1.000 41413 31002
plan_selfPlan NA NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA NA
barriers_self_cw 0.97 0.03 [ 0.91, 1.03] 0.850 [0.94, 1.06] 0.803 0.015 Very Strong Evidence for Null 1.000 24471 27118
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cw 1.00*** 0.00 [ 1.00, 1.00] 1.000 [0.94, 1.06] 1.000 1.696 Weak Evidence 1.000 46240 30780
Between-Person Effects
persuasion_self_cb 0.96 0.16 [ 0.69, 1.33] 0.603 [0.94, 1.06] 0.284 0.016 Very Strong Evidence for Null 1.001 5272 11415
persuasion_partner_cb 0.82 0.14 [ 0.59, 1.15] 0.881 [0.94, 1.06] 0.149 0.031 Strong Evidence for Null 1.001 5079 10623
pressure_self_cb 1.16 0.21 [ 0.81, 1.67] 0.787 [0.94, 1.06] 0.195 0.013 Very Strong Evidence for Null 1.000 8234 16693
pressure_partner_cb 1.06 0.19 [ 0.75, 1.51] 0.638 [0.94, 1.06] 0.262 0.011 Very Strong Evidence for Null 1.000 7053 14687
pushing_self_cb 1.14 0.27 [ 0.70, 1.82] 0.704 [0.94, 1.06] 0.177 0.015 Very Strong Evidence for Null 1.000 8007 14496
pushing_partner_cb 1.29 0.30 [ 0.81, 2.06] 0.863 [0.94, 1.06] 0.116 0.024 Very Strong Evidence for Null 1.000 7463 14575
barriers_self_cb 0.78*** 0.04 [ 0.70, 0.87] 1.000 [0.94, 1.06] 0.000 52.846 Very Strong Evidence 1.000 40907 31422
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 0.97 0.04 [ 0.89, 1.05] 0.791 [0.94, 1.06] 0.762 0.013 Very Strong Evidence for Null 1.000 25201 28784
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cb 1.00* 0.00 [ 1.00, 1.00] 0.989 [0.94, 1.06] 1.000 0.138 Moderate Evidence for Null 1.000 23810 28177
Interactions
persuasion_self_cw:barriers_self_cw 0.96 0.02 [ 0.92, 1.01] 0.919 [0.94, 1.06] 0.855 0.018 Very Strong Evidence for Null 1.000 34982 28834
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw 1.05 0.09 [ 0.89, 1.26] 0.734 [0.94, 1.06] 0.474 0.009 Very Strong Evidence for Null 1.000 24314 22052
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 0.98 0.03 [ 0.91, 1.05] 0.731 [0.94, 1.06] 0.873 0.008 Very Strong Evidence for Null 1.000 33379 29877
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 1.03 0.03 [ 0.98, 1.09] 0.888 [0.94, 1.06] 0.868 0.014 Very Strong Evidence for Null 1.000 33227 27717
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw 0.97 0.06 [ 0.85, 1.10] 0.700 [0.94, 1.06] 0.615 0.008 Very Strong Evidence for Null 1.000 34380 27698
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 1.07 0.04 [ 0.99, 1.16] 0.962 [0.94, 1.06] 0.419 0.032 Strong Evidence for Null 1.000 33826 28576
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 0.33 0.04 [0.25, 0.43] NA NA NA NA NA 1.000 9836 18223
sd(persuasion_self_cw) 0.06 0.02 [0.02, 0.10] NA NA NA NA NA 1.000 12418 9002
sd(persuasion_partner_cw) 0.05 0.02 [0.01, 0.10] NA NA NA NA NA 1.001 9286 8413
sd(pressure_self_cw) 0.07 0.06 [0.00, 0.24] NA NA NA NA NA 1.000 10882 15600
sd(pressure_partner_cw) 0.04 0.03 [0.00, 0.13] NA NA NA NA NA 1.000 19515 17192
sd(pushing_self_cw) 0.08 0.04 [0.01, 0.15] NA NA NA NA NA 1.000 8938 8950
sd(pushing_partner_cw) 0.05 0.03 [0.00, 0.11] NA NA NA NA NA 1.000 11007 13575
sd(barriers_self_cw) 0.14 0.03 [0.08, 0.21] NA NA NA NA NA 1.000 17799 20265
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma 0.53 0.01 [0.51, 0.55] NA NA NA NA NA 1.000 35524 29989
plot(
  bayestestR::p_direction(pa_obj_log),
  priors = TRUE
) + 
  coord_cartesian(xlim = c(-3, 3)) +
  theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple
## of shorter object length

plot(
  bayestestR::rope(pa_obj_log, range = rope_range_log, ci = 1)
) + theme_bw()
## Possible multicollinearity between b_persuasion_partner_cb and
##   b_persuasion_self_cb (r = 0.85), b_pressure_partner_cb and
##   b_persuasion_partner_cb (r = 0.7), b_pushing_partner_cb and
##   b_pushing_self_cb (r = 0.76). This might lead to inappropriate
##   results. See 'Details' in '?rope'.

# Nothing significant, no plots

Affect

range(df_double$aff, na.rm = T)
## [1] 0 5
hist(df_double$aff, breaks = 15)

Gaussian

formula <- bf(
  as.formula(
    paste("aff", formula_terms)
  )
  
  , decomp = 'QR'
  #, autocor = autocor_str
)


prior1 <- c(
  brms::set_prior("normal(0, 5)", class = "b")
  ,brms::set_prior("normal(0, 20)", class = "Intercept", lb=1, ub=6)
  , brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0)
  , brms::set_prior("student_t(3, 0, 2.5)", class = "sigma", lb = 0)
)

#brms::validate_prior(
#  prior1, 
#  formula = formula, 
#  data = df_double, 
#  family = gaussian()
#  )

#df_minimal <- df_double[, c("AorB", all.vars(as.formula(formula)))]

mood_gauss <- my_brm(
  mi = use_mi, 
  imputed_data = implist,
  
  formula = formula, 
  prior = prior1,
  data = df_double, 
  family = gaussian(),
  control = list(adapt_delta = 0.95),
  iter = iterations,
  warmup = warmup,
  chains = 4,
  cores = 4,
  seed = 7777,
  file = file.path("models_cache_brms", paste0("mood_gauss", suffix))
  #, file_refit = 'always'
)
## Warning: Rows containing NAs were excluded from the model.
mood_gauss_digest <- digest::digest(mood_gauss)
if (check_models) {
  check_brms(mood_gauss, log_pp_check = FALSE)
  DHARMa.check_brms.all(mood_gauss, integer = FALSE)
}
## # Check for Multicollinearity
## 
## Low Correlation
## 
##                   Term  VIF    VIF 95% CI Increased SE Tolerance
##     persuasion_self_cw 1.17 [1.13,  1.21]         1.08      0.86
##  persuasion_partner_cw 1.14 [1.11,  1.18]         1.07      0.88
##       pressure_self_cw 1.12 [1.09,  1.16]         1.06      0.89
##    pressure_partner_cw 1.07 [1.05,  1.12]         1.04      0.93
##        pushing_self_cw 1.26 [1.22,  1.31]         1.12      0.79
##     pushing_partner_cw 1.17 [1.13,  1.21]         1.08      0.86
##       pressure_self_cb 4.68 [4.44,  4.93]         2.16      0.21
##    pressure_partner_cb 4.59 [4.36,  4.84]         2.14      0.22
##       barriers_self_cb 1.09 [1.07,  1.14]         1.05      0.91
##   facilitators_self_cb 1.08 [1.05,  1.12]         1.04      0.92
##                    day 1.07 [1.04,  1.11]         1.03      0.94
##       barriers_self_cw 1.06 [1.03,  1.10]         1.03      0.95
##  Tolerance 95% CI
##      [0.82, 0.88]
##      [0.84, 0.90]
##      [0.86, 0.92]
##      [0.90, 0.95]
##      [0.76, 0.82]
##      [0.83, 0.88]
##      [0.20, 0.23]
##      [0.21, 0.23]
##      [0.88, 0.94]
##      [0.89, 0.95]
##      [0.90, 0.96]
##      [0.91, 0.97]
## 
## Moderate Correlation
## 
##                   Term  VIF    VIF 95% CI Increased SE Tolerance
##     persuasion_self_cb 9.89 [9.36, 10.45]         3.14      0.10
##  persuasion_partner_cb 9.73 [9.21, 10.29]         3.12      0.10
##        pushing_self_cb 7.20 [6.82,  7.61]         2.68      0.14
##     pushing_partner_cb 7.27 [6.89,  7.68]         2.70      0.14
##  Tolerance 95% CI
##      [0.10, 0.11]
##      [0.10, 0.11]
##      [0.13, 0.15]
##      [0.13, 0.15]
## # Distribution of Model Family
## 
## Predicted Distribution of Residuals
## 
##  Distribution Probability
##        normal         44%
##        cauchy         38%
##   exponential          6%
## 
## Predicted Distribution of Response
## 
##   Distribution Probability
##        tweedie         41%
##  beta-binomial         38%
##    half-cauchy          6%
## 
## Divergences:
## 0 of 40000 iterations ended with a divergence.
## 
## Tree depth:
## 0 of 40000 iterations saturated the maximum tree depth of 10.
## 
## Energy:
## E-BFMI indicated no pathological behavior.

## Using 10 posterior draws for ppc type 'ecdf_overlay' by default.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

## Warning: Found 9 observations with a pareto_k > 0.7 in model 'model'. We
## recommend to set 'moment_match = TRUE' in order to perform moment
## matching for problematic observations.

## 
##  DHARMa outlier test based on exact binomial test with
##  approximate expectations
## 
## data:  model.check
## outliers at both margin(s) = 7, observations = 1776, p-value =
## 0.09756
## alternative hypothesis: true probability of success is not equal to 0.001998002
## 95 percent confidence interval:
##  0.001586087 0.008103914
## sample estimates:
## frequency of outliers (expected: 0.001998001998002 ) 
##                                          0.003941441
if (do_priorsense) {
  gc()
  priorsense::powerscale_sensitivity(mood_gauss, variable = priorsense_vars)
  priorsense::powerscale_plot_dens(mood_gauss, variable = priorsense_vars)
  priorsense::powerscale_plot_ecdf(mood_gauss, variable = priorsense_vars)
  priorsense::powerscale_plot_quantities(mood_gauss, variable = priorsense_vars)
}
summary_mood <- summarize_brms(
  mood_gauss, 
  stats_to_report = stats_to_report,
  model_rows_fixed = model_rows_fixed,
  model_rows_random = model_rows_random,
  model_rownames_fixed = model_rownames_fixed,
  model_rownames_random = model_rownames_random,
  exponentiate = F) 
## Sampling priors, please wait...
## Warning in summarize_brms(mood_gauss, stats_to_report = stats_to_report,
## : Some rows from the model were omitted due to your provided
## model_rows_fixed or model_rows_random vectors. Missing rows:
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(mood_gauss, stats_to_report = stats_to_report,
## : Length of model_rownames does not match number of rows
summary_mood %>%
  print_df(
    rows_to_pack = rows_to_pack
    )
Est. SE 95% CI pd ROPE inside ROPE BF BF_Evidence Rhat Bulk_ESS Tail_ESS
Intercept 3.80*** 0.11 [ 3.59, 4.02] 1.000 [-0.11, 0.11] 0.000 >100 Overwhelming Evidence 1.000 9033 16338
Within-Person Effects
persuasion_self_cw 0.01 0.02 [-0.03, 0.06] 0.694 [-0.11, 0.11] 1.000 0.005 Very Strong Evidence for Null 1.000 58478 33456
persuasion_partner_cw 0.01 0.02 [-0.04, 0.06] 0.649 [-0.11, 0.11] 1.000 0.005 Very Strong Evidence for Null 1.000 58878 31925
pressure_self_cw -0.02 0.07 [-0.16, 0.11] 0.643 [-0.11, 0.11] 0.870 0.006 Very Strong Evidence for Null 1.000 51732 33773
pressure_partner_cw -0.04 0.06 [-0.17, 0.08] 0.749 [-0.11, 0.11] 0.862 0.006 Very Strong Evidence for Null 1.000 45660 30515
pushing_self_cw 0.02 0.04 [-0.06, 0.10] 0.696 [-0.11, 0.11] 0.986 0.006 Very Strong Evidence for Null 1.000 43875 35961
pushing_partner_cw 0.08 0.04 [ 0.00, 0.15] 0.973 [-0.11, 0.11] 0.796 0.042 Strong Evidence for Null 1.000 46215 32014
day 0.25** 0.07 [ 0.10, 0.39] 0.999 [-0.11, 0.11] 0.036 0.804 Weak Evidence for Null 1.000 77689 30117
plan_selfPlan NA NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA NA
barriers_self_cw -0.26*** 0.06 [-0.38, -0.12] 1.000 [-0.11, 0.11] 0.015 7.134 Moderate Evidence 1.000 31242 31401
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cw NA NA NA NA NA NA NA NA NA NA NA
Between-Person Effects
persuasion_self_cb 0.07 0.29 [-0.52, 0.63] 0.591 [-0.11, 0.11] 0.292 0.014 Very Strong Evidence for Null 1.000 9257 15757
persuasion_partner_cb 0.33 0.28 [-0.25, 0.89] 0.872 [-0.11, 0.11] 0.159 0.027 Very Strong Evidence for Null 1.000 9132 15341
pressure_self_cb -0.02 0.29 [-0.59, 0.56] 0.527 [-0.11, 0.11] 0.295 0.009 Very Strong Evidence for Null 1.000 11775 20704
pressure_partner_cb -0.27 0.29 [-0.83, 0.31] 0.825 [-0.11, 0.11] 0.192 0.014 Very Strong Evidence for Null 1.000 11380 20343
pushing_self_cb 0.22 0.41 [-0.61, 1.04] 0.704 [-0.11, 0.11] 0.184 0.014 Very Strong Evidence for Null 1.000 11891 19705
pushing_partner_cb 0.01 0.41 [-0.82, 0.82] 0.507 [-0.11, 0.11] 0.213 0.012 Very Strong Evidence for Null 1.000 11933 18765
barriers_self_cb -0.57*** 0.08 [-0.72, -0.41] 1.000 [-0.11, 0.11] 0.000 >100 Overwhelming Evidence 1.000 78957 31536
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 0.32*** 0.06 [ 0.21, 0.44] 1.000 [-0.11, 0.11] 0.000 >100 Overwhelming Evidence 1.000 47983 32535
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cb NA NA NA NA NA NA NA NA NA NA NA
Interactions
persuasion_self_cw:barriers_self_cw -0.01 0.04 [-0.09, 0.06] 0.600 [-0.11, 0.11] 0.992 0.005 Very Strong Evidence for Null 1.000 51568 32597
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw -0.15 0.17 [-0.51, 0.20] 0.810 [-0.11, 0.11] 0.352 0.012 Very Strong Evidence for Null 1.000 32979 31122
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 0.07 0.05 [-0.03, 0.17] 0.911 [-0.11, 0.11] 0.783 0.012 Very Strong Evidence for Null 1.000 52402 30949
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 0.02 0.04 [-0.05, 0.09] 0.729 [-0.11, 0.11] 0.991 0.005 Very Strong Evidence for Null 1.000 69494 32479
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw -0.06 0.10 [-0.27, 0.13] 0.730 [-0.11, 0.11] 0.663 0.007 Very Strong Evidence for Null 1.000 38996 30433
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 0.09 0.06 [-0.02, 0.22] 0.941 [-0.11, 0.11] 0.634 0.017 Very Strong Evidence for Null 1.000 37609 28398
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 0.61 0.08 [0.48, 0.79] NA NA NA NA NA 1.000 12201 21564
sd(persuasion_self_cw) 0.04 0.03 [0.00, 0.11] NA NA NA NA NA 1.000 16132 22554
sd(persuasion_partner_cw) 0.05 0.03 [0.00, 0.12] NA NA NA NA NA 1.000 13197 18920
sd(pressure_self_cw) 0.07 0.06 [0.00, 0.26] NA NA NA NA NA 1.000 23498 24276
sd(pressure_partner_cw) 0.08 0.07 [0.00, 0.28] NA NA NA NA NA 1.000 18844 21409
sd(pushing_self_cw) 0.09 0.05 [0.01, 0.20] NA NA NA NA NA 1.000 11728 13943
sd(pushing_partner_cw) 0.09 0.05 [0.01, 0.21] NA NA NA NA NA 1.000 14414 16923
sd(barriers_self_cw) 0.33 0.05 [0.24, 0.45] NA NA NA NA NA 1.000 30432 32326
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma 0.84 0.02 [0.81, 0.87] NA NA NA NA NA 1.000 61376 29276
plot(
  bayestestR::p_direction(mood_gauss),
  priors = TRUE
)  + 
  coord_cartesian(xlim = c(-3, 3)) +
  theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple
## of shorter object length

plot(
  bayestestR::rope(mood_gauss, ci = 1)
) + theme_bw()
## Possible multicollinearity between b_pressure_self_cb and
##   b_persuasion_self_cb (r = 0.75), b_pressure_partner_cb and
##   b_persuasion_self_cb (r = 0.72), b_pressure_self_cb and
##   b_persuasion_partner_cb (r = 0.72), b_pressure_partner_cb and
##   b_persuasion_partner_cb (r = 0.75), b_pushing_partner_cb and
##   b_pushing_self_cb (r = 0.84). This might lead to inappropriate
##   results. See 'Details' in '?rope'.

conditional_spaghetti(
  mood_gauss, 
  effects = c('pushing_partner_cw'),
  group_var = 'coupleID',
  plot_full_range = TRUE
)

$pushing_partner_cw

Reactance

range(df_double$reactance, na.rm = T) 
## [1] 0 5
hist(df_double$reactance, breaks = 7) 

hist(log(df_double$reactance+0.1), breaks = 10)

Ordinal

df_double$reactance_ordinal <- factor(df_double$reactance,
                                      levels = 0:5, 
                                      ordered = TRUE)

formula <- bf(
  as.formula(
    paste("reactance_ordinal", formula_terms)
  )
  
  , decomp = 'QR'
  #, autocor = autocor_str
)


prior1 <- c(
  brms::set_prior("normal(0, 2.5)", class = "b")
  , brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0)
)


#brms::validate_prior(
#  prior1, 
#  formula = formula, 
#  data = df_double, 
#  family = cumulative() # HURDLE_CUMULATIVE
#  )


#df_minimal <- df_double[, c("AorB", all.vars(as.formula(formula)))]

reactance_ordinal <- my_brm(
  mi = use_mi, 
  imputed_data = implist,
  
  formula = formula, 
  prior = prior1,
  data = df_double, 
  family = brms::cumulative(),
  #control = list(adapt_delta = 0.95),
  iter = iterations,
  warmup = warmup,
  chains = 4,
  cores = 4,
  seed = 7777
  , file = file.path("models_cache_brms", paste0("reactance_ordinal", suffix))
)
## Warning: Rows containing NAs were excluded from the model.
reactance_ordinal_digest <- digest::digest(reactance_ordinal)
if (check_models) {
  check_brms(reactance_ordinal)
  DHARMa.check_brms.all(reactance_ordinal, outliers_type = 'bootstrap')
}
## # Check for Multicollinearity
## 
## Low Correlation
## 
##                   Term  VIF    VIF 95% CI Increased SE Tolerance
##       pressure_self_cw 4.08 [3.86,  4.32]         2.02      0.25
##    pressure_partner_cw 1.45 [1.39,  1.51]         1.20      0.69
##        pushing_self_cw 1.23 [1.19,  1.29]         1.11      0.81
##     pushing_partner_cw 1.18 [1.14,  1.23]         1.09      0.84
##     persuasion_self_cb 1.07 [1.04,  1.12]         1.04      0.93
##  persuasion_partner_cb 1.10 [1.07,  1.15]         1.05      0.91
##       pressure_self_cb 1.29 [1.24,  1.34]         1.13      0.78
##    pressure_partner_cb 1.28 [1.24,  1.34]         1.13      0.78
##        pushing_self_cb 4.91 [4.63,  5.21]         2.22      0.20
##   facilitators_self_cb 5.00 [4.71,  5.30]         2.24      0.20
##                    day 2.07 [1.97,  2.17]         1.44      0.48
##       barriers_self_cw 2.35 [2.24,  2.48]         1.53      0.42
##  Tolerance 95% CI
##      [0.23, 0.26]
##      [0.66, 0.72]
##      [0.78, 0.84]
##      [0.81, 0.87]
##      [0.89, 0.96]
##      [0.87, 0.94]
##      [0.75, 0.81]
##      [0.75, 0.81]
##      [0.19, 0.22]
##      [0.19, 0.21]
##      [0.46, 0.51]
##      [0.40, 0.45]
## 
## Moderate Correlation
## 
##                   Term  VIF    VIF 95% CI Increased SE Tolerance
##     persuasion_self_cw 8.13 [7.65,  8.64]         2.85      0.12
##  persuasion_partner_cw 9.88 [9.29, 10.51]         3.14      0.10
##     pushing_partner_cb 6.22 [5.86,  6.61]         2.49      0.16
##       barriers_self_cb 5.12 [4.83,  5.43]         2.26      0.20
##  Tolerance 95% CI
##      [0.12, 0.13]
##      [0.10, 0.11]
##      [0.15, 0.17]
##      [0.18, 0.21]
## Error in h(simpleError(msg, call)) : 
##   error in evaluating the argument 'x' in selecting a method for function 'print': Predictive errors are not defined for ordinal or categorical models.
## 
## Divergences:
## 0 of 40000 iterations ended with a divergence.
## 
## Tree depth:
## 0 of 40000 iterations saturated the maximum tree depth of 10.
## 
## Energy:
## E-BFMI indicated no pathological behavior.

## Using 10 posterior draws for ppc type 'ecdf_overlay' by default.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

## Warning: Found 33 observations with a pareto_k > 0.7 in model 'model'.
## We recommend to set 'moment_match = TRUE' in order to perform moment
## matching for problematic observations.

## 
##  DHARMa bootstrapped outlier test
## 
## data:  model.check
## outliers at both margin(s) = 1, observations = 486, p-value =
## 0.4
## alternative hypothesis: two.sided
##  percent confidence interval:
##  0.000000000 0.002057613
## sample estimates:
## outlier frequency (expected: 0.000411522633744856 ) 
##                                         0.002057613
if (do_priorsense) {
  gc()
  priorsense::powerscale_sensitivity(reactance_ordinal, variable = priorsense_vars)
  priorsense::powerscale_plot_dens(reactance_ordinal, variable = priorsense_vars)
  priorsense::powerscale_plot_ecdf(reactance_ordinal, variable = priorsense_vars)
  priorsense::powerscale_plot_quantities(reactance_ordinal, variable = priorsense_vars)
}
summary_reactance_ordinal <- summarize_brms(
  reactance_ordinal, 
  stats_to_report = stats_to_report,
  rope_range = c(-0.18, 0.18),
  model_rows_fixed = model_rows_fixed_ordinal,
  model_rows_random = model_rows_random_ordinal,
  model_rownames_fixed = model_rownames_fixed_ordinal,
  model_rownames_random = model_rownames_random_ordinal,
  exponentiate = T) 
## Sampling priors, please wait...

===> warning: knot 3 removed - double knot ===> warning: knot 4 removed - double knot ===> warning: knot 5 removed - double knot * several double knots suggests that your data is strongly rounded, attention might be required possible infinite density at lower end running program with fewer knots ===> warning: knot 3 removed - double knot ===> warning: knot 4 removed - double knot ===> warning: knot 5 removed - double knot several double knots suggests that your data is strongly rounded, attention might be required * possible infinite density at lower end running program with fewer knots

## Warning in summarize_brms(reactance_ordinal, stats_to_report =
## stats_to_report, : Some rows from the model were omitted due to your
## provided model_rows_fixed or model_rows_random vectors. Missing rows:
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(reactance_ordinal, stats_to_report =
## stats_to_report, : Length of model_rownames does not match number of
## rows
summary_reactance_ordinal %>%
  print_df(
    rows_to_pack = rows_to_pack_ordinal
    )
OR SE 95% CI pd ROPE inside ROPE BF BF_Evidence Rhat Bulk_ESS Tail_ESS
Intercept NA NA NA NA NA NA NA NA NA NA NA
Intercept[1] 4.62*** 1.92 [ 2.06, 10.96] 1.000 [0.84, 1.20] 0.001 30.213 Very Strong Evidence 1.000 49636 35952
Intercept[2] 11.18*** 4.82 [ 4.87, 27.84] 1.000 [0.84, 1.20] 0.000 >100 Overwhelming Evidence 1.000 48764 34385
Intercept[3] 35.95*** 16.93 [ 14.79, 98.03] 1.000 [0.84, 1.20] 0.000 >100 Overwhelming Evidence 1.000 45655 32137
Intercept[4] 191.28*** 107.60 [ 67.26, 619.86] 1.000 [0.84, 1.20] 0.000 >100 Overwhelming Evidence 1.000 43599 32714
Intercept[5] 5962.77*** 6286.89 [965.89, 67535.08] 1.000 [0.84, 1.20] 0.000 >100 Overwhelming Evidence 1.000 53557 31040
Within-Person Effects
persuasion_self_cw 0.67** 0.09 [ 0.49, 0.87] 0.998 [0.84, 1.20] 0.050 5.148 Moderate Evidence 1.000 38402 27272
persuasion_partner_cw 0.91 0.15 [ 0.62, 1.24] 0.720 [0.84, 1.20] 0.641 0.086 Strong Evidence for Null 1.000 37579 31837
pressure_self_cw 1.76 0.53 [ 0.88, 3.27] 0.950 [0.84, 1.20] 0.101 0.452 Weak Evidence for Null 1.000 36287 29812
pressure_partner_cw 1.22 0.48 [ 0.46, 2.64] 0.685 [0.84, 1.20] 0.299 0.105 Moderate Evidence for Null 1.000 36023 25749
pushing_self_cw 1.39* 0.21 [ 1.02, 1.89] 0.980 [0.84, 1.20] 0.166 0.634 Weak Evidence for Null 1.000 43760 33120
pushing_partner_cw 0.93 0.18 [ 0.63, 1.38] 0.645 [0.84, 1.20] 0.613 0.075 Strong Evidence for Null 1.000 47812 32684
day 1.35 0.75 [ 0.45, 4.02] 0.708 [0.84, 1.20] 0.218 0.069 Strong Evidence for Null 1.000 59738 33884
plan_selfPlan NA NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA NA
barriers_self_cw 1.00 0.41 [ 0.44, 2.26] 0.502 [0.84, 1.20] 0.343 0.073 Strong Evidence for Null 1.000 46807 34930
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cw NA NA NA NA NA NA NA NA NA NA NA
Between-Person Effects
persuasion_self_cb 1.46 1.25 [ 0.26, 8.46] 0.671 [0.84, 1.20] 0.149 0.097 Strong Evidence for Null 1.000 32017 31779
persuasion_partner_cb 1.81 1.73 [ 0.29, 13.62] 0.735 [0.84, 1.20] 0.125 0.108 Moderate Evidence for Null 1.000 32530 31009
pressure_self_cb 2.68 2.77 [ 0.35, 22.07] 0.826 [0.84, 1.20] 0.089 0.118 Moderate Evidence for Null 1.000 38087 35401
pressure_partner_cb 1.26 1.24 [ 0.16, 8.36] 0.594 [0.84, 1.20] 0.139 0.075 Strong Evidence for Null 1.000 32420 32304
pushing_self_cb 0.93 1.14 [ 0.08, 11.41] 0.521 [0.84, 1.20] 0.117 0.083 Strong Evidence for Null 1.000 33503 31761
pushing_partner_cb 0.02** 0.03 [ 0.00, 0.41] 0.995 [0.84, 1.20] 0.004 2.465 Weak Evidence 1.000 35224 32193
barriers_self_cb 0.99 0.71 [ 0.23, 4.07] 0.506 [0.84, 1.20] 0.198 0.075 Strong Evidence for Null 1.000 47717 34334
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 0.80 0.35 [ 0.34, 1.95] 0.690 [0.84, 1.20] 0.280 0.107 Moderate Evidence for Null 1.000 43079 32459
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cb NA NA NA NA NA NA NA NA NA NA NA
Interactions
persuasion_self_cw:barriers_self_cw 0.72 0.15 [ 0.46, 1.09] 0.940 [0.84, 1.20] 0.234 0.289 Moderate Evidence for Null 1.000 46083 33103
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw 1.88 0.81 [ 0.74, 4.55] 0.919 [0.84, 1.20] 0.116 0.232 Moderate Evidence for Null 1.000 33935 30324
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 0.78 0.19 [ 0.45, 1.27] 0.849 [0.84, 1.20] 0.347 0.124 Moderate Evidence for Null 1.000 40811 31072
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 1.39 0.42 [ 0.73, 2.67] 0.860 [0.84, 1.20] 0.256 0.171 Moderate Evidence for Null 1.000 43165 30649
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw 0.88 0.60 [ 0.22, 3.96] 0.574 [0.84, 1.20] 0.201 0.098 Strong Evidence for Null 1.000 38959 30418
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 1.36 0.48 [ 0.68, 2.77] 0.813 [0.84, 1.20] 0.273 0.118 Moderate Evidence for Null 1.000 51231 33221
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 1.22 0.32 [0.69, 1.99] NA NA NA NA NA 1.000 18872 27617
sd(persuasion_self_cw) 0.33 0.22 [0.02, 0.78] NA NA NA NA NA 1.000 10491 18771
sd(persuasion_partner_cw) 0.21 0.17 [0.01, 0.64] NA NA NA NA NA 1.000 22296 24694
sd(pressure_self_cw) 0.81 0.42 [0.12, 1.86] NA NA NA NA NA 1.000 13988 15164
sd(pressure_partner_cw) 0.56 0.49 [0.02, 2.07] NA NA NA NA NA 1.000 17825 24858
sd(pushing_self_cw) 0.31 0.23 [0.02, 0.83] NA NA NA NA NA 1.000 12985 21502
sd(pushing_partner_cw) 0.24 0.21 [0.01, 0.87] NA NA NA NA NA 1.000 20012 26071
sd(barriers_self_cw) 1.03 0.50 [0.11, 2.07] NA NA NA NA NA 1.000 14688 15119
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma NA NA NA NA NA NA NA NA NA NA NA
disc 1.00 0.00 [1.00, 1.00] NA NA NA NA NA NA NA NA
plot(
  bayestestR::p_direction(reactance_ordinal),
  priors = TRUE
) + 
  coord_cartesian(xlim = c(-6, 6)) +
  theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple
## of shorter object length

plot(
  bayestestR::rope(reactance_ordinal, range = c(-0.18, 0.18), ci = 1)
) + theme_bw()
## Possible multicollinearity between b_Intercept[4] and
##   b_Intercept[2] (r = 0.79), b_Intercept[4] and b_Intercept[3] (r =
##   0.85), b_pressure_partner_cb and b_persuasion_partner_cb (r =
##   0.77). This might lead to inappropriate results. See 'Details' in
##   '?rope'.

#conditional_spaghetti(
#  reactance_ordinal, 
#  effects = c('persuasion_self_cw', 'pressure_self_cw')
#  , group_var = 'coupleID'
#  #, n_groups = 15
#  , plot_full_range = T
#)

Binary

introduce_binary_reactance <- function(data) {
  data$is_reactance <- factor(data$reactance > 0, levels = c(FALSE, TRUE), labels = c(0, 1))
  return(data)
}



df_double <- introduce_binary_reactance(df_double)
if (use_mi) {
  for (i in seq_along(implist)) {
    implist[[i]] <- introduce_binary_reactance(implist[[i]])
  }
}


formula <- bf(
  as.formula(
    paste("is_reactance", formula_terms)
  )
  
  , decomp = 'QR'
  #, autocor = autocor_str
  )



prior1 <- c(
  brms::set_prior("normal(0, 2.5)", class = "b")
  , brms::set_prior("normal(0, 10)", class = "Intercept", lb=0, ub=5) 
  , brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0)
)


#brms::validate_prior(
#  prior1, 
#  formula = formula, 
#  data = df_double, 
#  family = bernoulli()
#  )



#df_minimal <- df_double[, c("AorB", all.vars(as.formula(formula)))]

is_reactance <- my_brm(
  mi = use_mi, 
  imputed_data = implist,
  
  formula = formula, 
  prior = prior1,
  data = df_double, 
  family = brms::bernoulli(),
  #control = list(adapt_delta = 0.95, max_treedepth = 15),
  iter = iterations,
  warmup = warmup,
  chains = 4,
  cores = 4,
  seed = 7777,
  file = file.path("models_cache_brms", paste0("is_reactance", suffix))
  #, file_refit = 'always'
)
## Warning: Rows containing NAs were excluded from the model.
is_reactance_digest <- digest::digest(is_reactance)
if (check_models) {
  check_brms(is_reactance)
  DHARMa.check_brms.all(is_reactance, integer = FALSE)
}
## # Check for Multicollinearity
## 
## Low Correlation
## 
##                   Term  VIF   VIF 95% CI Increased SE Tolerance
##     persuasion_self_cw 1.11 [1.08, 1.16]         1.05      0.90
##  persuasion_partner_cw 1.25 [1.20, 1.30]         1.12      0.80
##       pressure_self_cw 1.04 [1.02, 1.10]         1.02      0.96
##    pressure_partner_cw 1.05 [1.03, 1.10]         1.03      0.95
##        pushing_self_cw 1.11 [1.08, 1.16]         1.06      0.90
##     pushing_partner_cw 1.33 [1.28, 1.38]         1.15      0.75
##     persuasion_self_cb 3.66 [3.46, 3.87]         1.91      0.27
##  persuasion_partner_cb 3.82 [3.62, 4.04]         1.95      0.26
##       pressure_self_cb 2.35 [2.24, 2.47]         1.53      0.43
##    pressure_partner_cb 2.27 [2.17, 2.39]         1.51      0.44
##        pushing_self_cb 2.35 [2.24, 2.48]         1.53      0.43
##     pushing_partner_cb 2.30 [2.19, 2.42]         1.52      0.44
##       barriers_self_cb 1.24 [1.19, 1.29]         1.11      0.81
##   facilitators_self_cb 1.08 [1.05, 1.12]         1.04      0.93
##                    day 1.05 [1.03, 1.10]         1.03      0.95
##       barriers_self_cw 1.40 [1.34, 1.46]         1.18      0.72
##  Tolerance 95% CI
##      [0.86, 0.93]
##      [0.77, 0.83]
##      [0.91, 0.98]
##      [0.91, 0.97]
##      [0.86, 0.93]
##      [0.72, 0.78]
##      [0.26, 0.29]
##      [0.25, 0.28]
##      [0.40, 0.45]
##      [0.42, 0.46]
##      [0.40, 0.45]
##      [0.41, 0.46]
##      [0.78, 0.84]
##      [0.89, 0.95]
##      [0.91, 0.97]
##      [0.69, 0.74]
## # Distribution of Model Family
## 
## Predicted Distribution of Residuals
## 
##  Distribution Probability
##        normal         31%
##          beta         19%
##        cauchy         19%
## 
## Predicted Distribution of Response
## 
##   Distribution Probability
##      bernoulli         75%
##  beta-binomial         16%
##       binomial          9%
## 
## Divergences:
## 0 of 40000 iterations ended with a divergence.
## 
## Tree depth:
## 0 of 40000 iterations saturated the maximum tree depth of 10.
## 
## Energy:
## E-BFMI indicated no pathological behavior.

## Using 10 posterior draws for ppc type 'ecdf_overlay' by default.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

## Warning: Found 96 observations with a pareto_k > 0.7 in model 'model'.
## We recommend to set 'moment_match = TRUE' in order to perform moment
## matching for problematic observations.

## 
##  DHARMa outlier test based on exact binomial test with
##  approximate expectations
## 
## data:  model.check
## outliers at both margin(s) = 0, observations = 486, p-value = 1
## alternative hypothesis: true probability of success is not equal to 0.001998002
## 95 percent confidence interval:
##  0.000000000 0.007561553
## sample estimates:
## frequency of outliers (expected: 0.001998001998002 ) 
##                                                    0
if (do_priorsense) {
  gc()
  priorsense::powerscale_sensitivity(is_reactance, variable = priorsense_vars)
  priorsense::powerscale_plot_dens(is_reactance, variable = priorsense_vars)
  priorsense::powerscale_plot_ecdf(is_reactance, variable = priorsense_vars)
  priorsense::powerscale_plot_quantities(is_reactance, variable = priorsense_vars)
}
summary_is_reactance <- summarize_brms(
  is_reactance, 
  stats_to_report = stats_to_report,
  model_rows_fixed = model_rows_fixed,
  model_rows_random = model_rows_random,
  model_rownames_fixed = model_rownames_fixed,
  model_rownames_random = model_rownames_random,
  exponentiate = T) 
## Sampling priors, please wait...
## Warning in summarize_brms(is_reactance, stats_to_report =
## stats_to_report, : Some rows from the model were omitted due to your
## provided model_rows_fixed or model_rows_random vectors. Missing rows:
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(is_reactance, stats_to_report =
## stats_to_report, : Length of model_rownames does not match number of
## rows
summary_is_reactance %>%
  print_df(
    rows_to_pack = rows_to_pack
    )
OR SE 95% CI pd ROPE inside ROPE BF BF_Evidence Rhat Bulk_ESS Tail_ESS
Intercept 0.47 0.24 [0.16, 1.34] 0.924 [0.83, 1.20] 0.095 0.253 Moderate Evidence for Null 1.000 33627 33018
Within-Person Effects
persuasion_self_cw 0.63* 0.14 [0.38, 0.95] 0.986 [0.83, 1.20] 0.084 1.396 Weak Evidence 1.000 28023 28635
persuasion_partner_cw 1.07 0.32 [0.60, 2.14] 0.596 [0.83, 1.20] 0.453 0.132 Moderate Evidence for Null 1.000 24199 24283
pressure_self_cw 4.29* 3.57 [1.00, 32.57] 0.975 [0.83, 1.20] 0.028 1.590 Weak Evidence 1.000 22611 23694
pressure_partner_cw 1.64 1.47 [0.26, 16.69] 0.716 [0.83, 1.20] 0.142 0.223 Moderate Evidence for Null 1.000 27214 25172
pushing_self_cw 1.70* 0.42 [1.10, 3.13] 0.991 [0.83, 1.20] 0.060 1.632 Weak Evidence 1.000 22475 26993
pushing_partner_cw 0.83 0.30 [0.40, 1.85] 0.699 [0.83, 1.20] 0.335 0.157 Moderate Evidence for Null 1.000 30415 26455
day 1.42 1.01 [0.34, 5.70] 0.690 [0.83, 1.20] 0.178 0.087 Strong Evidence for Null 1.000 49157 32314
plan_selfPlan NA NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA NA
barriers_self_cw 0.82 0.48 [0.25, 2.82] 0.633 [0.83, 1.20] 0.228 0.114 Moderate Evidence for Null 1.000 37379 32322
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cw NA NA NA NA NA NA NA NA NA NA NA
Between-Person Effects
persuasion_self_cb 4.16 5.95 [0.25, 90.18] 0.844 [0.83, 1.20] 0.061 0.246 Moderate Evidence for Null 1.000 18736 24685
persuasion_partner_cb 7.65 11.79 [0.42, 218.29] 0.914 [0.83, 1.20] 0.040 0.344 Weak Evidence for Null 1.000 18245 24902
pressure_self_cb 68.56 167.69 [0.81, 13217.49] 0.969 [0.83, 1.20] 0.012 0.881 Weak Evidence for Null 1.000 23568 27135
pressure_partner_cb 0.65 1.76 [0.00, 111.32] 0.562 [0.83, 1.20] 0.054 0.202 Moderate Evidence for Null 1.000 17143 26302
pushing_self_cb 0.81 1.77 [0.01, 59.15] 0.537 [0.83, 1.20] 0.065 0.150 Moderate Evidence for Null 1.000 20753 27025
pushing_partner_cb 0.01* 0.02 [0.00, 0.70] 0.983 [0.83, 1.20] 0.007 1.449 Weak Evidence 1.000 20611 27523
barriers_self_cb 0.67 0.75 [0.07, 5.80] 0.638 [0.83, 1.20] 0.120 0.123 Moderate Evidence for Null 1.000 32817 31595
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 0.99 0.66 [0.26, 3.96] 0.508 [0.83, 1.20] 0.212 0.144 Moderate Evidence for Null 1.000 26899 29198
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA NA
weartime_self_cb NA NA NA NA NA NA NA NA NA NA NA
Interactions
persuasion_self_cw:barriers_self_cw 0.93 0.26 [0.51, 1.65] 0.601 [0.83, 1.20] 0.462 0.120 Moderate Evidence for Null 1.000 37266 31546
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw 1.71 1.47 [0.27, 11.16] 0.735 [0.83, 1.20] 0.137 0.188 Moderate Evidence for Null 1.000 27968 29099
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 0.67 0.28 [0.26, 1.47] 0.845 [0.83, 1.20] 0.223 0.202 Moderate Evidence for Null 1.000 29742 27471
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 1.37 0.70 [0.46, 4.36] 0.734 [0.83, 1.20] 0.228 0.182 Moderate Evidence for Null 1.000 30625 27331
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw 0.86 1.18 [0.05, 17.62] 0.546 [0.83, 1.20] 0.107 0.193 Moderate Evidence for Null 1.000 30311 28639
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 1.76 0.97 [0.59, 5.63] 0.847 [0.83, 1.20] 0.154 0.211 Moderate Evidence for Null 1.000 40322 30462
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 2.49 0.57 [1.54, 3.87] NA NA NA NA NA 1.001 13566 23976
sd(persuasion_self_cw) 0.68 0.31 [0.08, 1.39] NA NA NA NA NA 1.001 6918 8734
sd(persuasion_partner_cw) 0.76 0.44 [0.07, 1.83] NA NA NA NA NA 1.000 10555 14198
sd(pressure_self_cw) 2.41 0.92 [0.87, 4.59] NA NA NA NA NA 1.000 15602 15620
sd(pressure_partner_cw) 1.84 1.20 [0.13, 4.57] NA NA NA NA NA 1.000 14595 15886
sd(pushing_self_cw) 0.62 0.36 [0.05, 1.47] NA NA NA NA NA 1.000 9022 12138
sd(pushing_partner_cw) 0.51 0.43 [0.02, 1.72] NA NA NA NA NA 1.000 13904 21185
sd(barriers_self_cw) 1.52 0.67 [0.24, 2.97] NA NA NA NA NA 1.000 11717 10547
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma NA NA NA NA NA NA NA NA NA NA NA
plot(
  bayestestR::p_direction(is_reactance),
  priors = TRUE
) + 
  coord_cartesian(xlim = c(-6, 6)) +
  theme_bw()
## Warning in `==.default`(dens$Parameter, parameter): longer object length
## is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple
## of shorter object length

plot(
  bayestestR::rope(is_reactance, ci = 1)
) + theme_bw()
## Possible multicollinearity between b_persuasion_partner_cb and
##   b_persuasion_self_cb (r = 0.72). This might lead to inappropriate
##   results. See 'Details' in '?rope'.

conditional_spaghetti(
  is_reactance, 
  effects = c('pressure_self_cw', 'pushing_self_cw'),
  group_var = 'coupleID',
  plot_full_range = TRUE
)

\(pressure_self_cw <img src="07_SensitivityBarriersFacilitatorsInteract_files/figure-html/report_is_reactance-3.png" width="2400" />\)pushing_self_cw

hypothesis(is_reactance, "exp(pressure_self_cw) > exp(pushing_self_cw)")
## Hypothesis Tests for class b:
##                 Hypothesis Estimate Est.Error CI.Lower CI.Upper
## 1 (exp(pressure_sel... > 0     5.59     13.16    -0.74    20.62
##   Evid.Ratio Post.Prob Star
## 1       6.48      0.87     
## ---
## 'CI': 90%-CI for one-sided and 95%-CI for two-sided hypotheses.
## '*': For one-sided hypotheses, the posterior probability exceeds 95%;
## for two-sided hypotheses, the value tested against lies outside the 95%-CI.
## Posterior probabilities of point hypotheses assume equal prior probabilities.

Report All Models

summary_all_models <- report_side_by_side(
  pa_sub,
  pa_obj_log,
  mood_gauss,
  is_reactance,
  
  stats_to_report = c('CI'),
  model_rows_random = model_rows_random,
  model_rows_fixed = model_rows_fixed,
  model_rownames_random = model_rownames_random,
  model_rownames_fixed = model_rownames_fixed
)

[1] “pa_sub”

## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Coefficients were exponentiated.
## Double check if this was intended.
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Some rows from the model were
## omitted due to your provided model_rows_fixed or model_rows_random
## vectors. Missing rows: sd(persuasion_partner_cw:barriers_self_cw),
## sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw)
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Length of model_rownames does not
## match number of rows

[1] “pa_obj_log”

## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Coefficients were exponentiated.
## Double check if this was intended.
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Some rows from the model were
## omitted due to your provided model_rows_fixed or model_rows_random
## vectors. Missing rows: sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Length of model_rownames does not
## match number of rows

[1] “mood_gauss”

## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Some rows from the model were
## omitted due to your provided model_rows_fixed or model_rows_random
## vectors. Missing rows: sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Length of model_rownames does not
## match number of rows

[1] “is_reactance”

## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Some rows from the model were
## omitted due to your provided model_rows_fixed or model_rows_random
## vectors. Missing rows: sd(persuasion_self_cw:barriers_self_cw),
## sd(pressure_self_cw:barriers_self_cw),
## sd(pushing_self_cw:barriers_self_cw),
## sd(persuasion_partner_cw:barriers_self_cw),
## sd(pressure_partner_cw:barriers_self_cw),
## sd(pushing_partner_cw:barriers_self_cw)
## Warning in summarize_brms(model, exponentiate = exponentiate,
## stats_to_report = stats_to_report, : Length of model_rownames does not
## match number of rows
summary_all_models <- summary_all_models %>%
  print_df(
    rows_to_pack = rows_to_pack
    ) %>%
  add_header_above(
    c(
      " ", "Hurdle Component" = 2, "Non-Zero Component" = 2,
      " " = 6
    )
  ) %>%
  add_header_above(
    c(" ", "Subjective MVPA Hurdle Lognormal" = 4,  
      "Device-Based MVPA Log (Gaussian)" = 2, 
      "Mood Gaussian" = 2,
      #"Reactance Ordinal" = 2,
      "Reactance Dichotome" = 2
    )
  )

export_xlsx(
  summary_all_models, 
  rows_to_pack = rows_to_pack,
  file.path("Output", paste0("AllModels", suffix, ".xlsx")), 
  merge_option = 'both', 
  simplify_2nd_row = FALSE,
  line_above_rows = c(1,2),
  line_below_rows = c(-1)
)

  
summary_all_models
Subjective MVPA Hurdle Lognormal
Device-Based MVPA Log (Gaussian)
Mood Gaussian
Reactance Dichotome
Hurdle Component
Non-Zero Component
exp(Est.)_hu pa_sub 95% CI_hu pa_sub exp(Est.)_nonzero pa_sub 95% CI_nonzero pa_sub exp(Est.) pa_obj_log 95% CI pa_obj_log Est. mood_gauss 95% CI mood_gauss OR is_reactance 95% CI is_reactance
Intercept 2.89*** [ 1.62, 5.14] 49.15*** [41.78, 58.06] 122.92*** [108.77, 138.83] 3.80*** [ 3.59, 4.02] 0.47 [0.16, 1.34]
Within-Person Effects
persuasion_self_cw 1.61*** [ 1.30, 2.07] 1.04 [ 0.99, 1.10] 1.03 [ 0.99, 1.06] 0.01 [-0.03, 0.06] 0.63* [0.38, 0.95]
persuasion_partner_cw 1.44*** [ 1.17, 1.86] 1.02 [ 0.98, 1.07] 1.03 [ 0.99, 1.07] 0.01 [-0.04, 0.06] 1.07 [0.60, 2.14]
pressure_self_cw 0.84 [ 0.43, 1.92] 0.90 [ 0.78, 1.03] 0.95 [ 0.85, 1.05] -0.02 [-0.16, 0.11] 4.29* [1.00, 32.57]
pressure_partner_cw 1.64 [ 0.85, 5.26] 0.96 [ 0.86, 1.06] 0.98 [ 0.90, 1.06] -0.04 [-0.17, 0.08] 1.64 [0.26, 16.69]
pushing_self_cw 1.22 [ 0.82, 1.84] 0.98 [ 0.92, 1.05] 1.03 [ 0.97, 1.08] 0.02 [-0.06, 0.10] 1.70* [1.10, 3.13]
pushing_partner_cw 1.60* [ 1.07, 2.78] 0.96 [ 0.90, 1.02] 0.99 [ 0.94, 1.04] 0.08 [ 0.00, 0.15] 0.83 [0.40, 1.85]
day 0.88 [ 0.54, 1.42] 1.03 [ 0.89, 1.18] 0.97 [ 0.88, 1.07] 0.25** [ 0.10, 0.39] 1.42 [0.34, 5.70]
plan_selfPlan NA NA NA NA NA NA NA NA NA NA
plan_partnerPlan NA NA NA NA NA NA NA NA NA NA
barriers_self_cw 0.68 [ 0.42, 1.12] 1.08 [ 0.97, 1.20] 0.97 [ 0.91, 1.03] -0.26*** [-0.38, -0.12] 0.82 [0.25, 2.82]
barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
weartime_self_cw NA NA NA NA 1.00*** [ 1.00, 1.00] NA NA NA NA
Between-Person Effects
persuasion_self_cb 0.91 [ 0.25, 3.09] 1.07 [ 0.76, 1.50] 0.96 [ 0.69, 1.33] 0.07 [-0.52, 0.63] 4.16 [0.25, 90.18]
persuasion_partner_cb 1.35 [ 0.38, 4.59] 0.94 [ 0.67, 1.31] 0.82 [ 0.59, 1.15] 0.33 [-0.25, 0.89] 7.65 [0.42, 218.29]
pressure_self_cb 0.23 [ 0.04, 1.24] 0.69 [ 0.31, 1.59] 1.16 [ 0.81, 1.67] -0.02 [-0.59, 0.56] 68.56 [0.81, 13217.49]
pressure_partner_cb 0.20 [ 0.03, 1.03] 0.51 [ 0.23, 1.17] 1.06 [ 0.75, 1.51] -0.27 [-0.83, 0.31] 0.65 [0.00, 111.32]
pushing_self_cb 1.35 [ 0.23, 7.96] 1.50 [ 0.83, 2.70] 1.14 [ 0.70, 1.82] 0.22 [-0.61, 1.04] 0.81 [0.01, 59.15]
pushing_partner_cb 1.76 [ 0.30, 10.33] 1.65 [ 0.91, 2.95] 1.29 [ 0.81, 2.06] 0.01 [-0.82, 0.82] 0.01* [0.00, 0.70]
barriers_self_cb 0.50** [ 0.30, 0.83] 0.92 [ 0.78, 1.09] 0.78*** [ 0.70, 0.87] -0.57*** [-0.72, -0.41] 0.67 [0.07, 5.80]
barriers_partner_cb NA NA NA NA NA NA NA NA NA NA
facilitators_self_cb 1.20 [ 0.82, 1.77] 1.14* [ 1.03, 1.27] 0.97 [ 0.89, 1.05] 0.32*** [ 0.21, 0.44] 0.99 [0.26, 3.96]
facilitators_partner_cb NA NA NA NA NA NA NA NA NA NA
weartime_self_cb NA NA NA NA 1.00* [ 1.00, 1.00] NA NA NA NA
Interactions
persuasion_self_cw:barriers_self_cw 0.95 [ 0.62, 1.46] 0.99 [ 0.92, 1.07] 0.96 [ 0.92, 1.01] -0.01 [-0.09, 0.06] 0.93 [0.51, 1.65]
barriers_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_self_cw 0.49 [ 0.15, 1.54] 1.02 [ 0.79, 1.31] 1.05 [ 0.89, 1.26] -0.15 [-0.51, 0.20] 1.71 [0.27, 11.16]
barriers_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_self_cw 1.94 [ 0.99, 4.10] 0.96 [ 0.86, 1.07] 0.98 [ 0.91, 1.05] 0.07 [-0.03, 0.17] 0.67 [0.26, 1.47]
barriers_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_self_cw 0.68* [ 0.46, 0.95] 1.06 [ 0.99, 1.13] 1.03 [ 0.98, 1.09] 0.02 [-0.05, 0.09] 1.37 [0.46, 4.36]
barriers_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_self_cw 0.82 [ 0.26, 2.53] 0.90 [ 0.75, 1.05] 0.97 [ 0.85, 1.10] -0.06 [-0.27, 0.13] 0.86 [0.05, 17.62]
barriers_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_self_cw 1.71 [ 0.99, 3.43] 1.05 [ 0.95, 1.18] 1.07 [ 0.99, 1.16] 0.09 [-0.02, 0.22] 1.76 [0.59, 5.63]
barriers_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_self_cw NA NA NA NA NA NA NA NA NA NA
facilitators_self_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA
persuasion_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_self_cw NA NA NA NA NA NA NA NA NA NA
pressure_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_self_cw NA NA NA NA NA NA NA NA NA NA
pushing_self_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_self_cw NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:barriers_partner_cw NA NA NA NA NA NA NA NA NA NA
barriers_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA
persuasion_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:persuasion_partner_cw NA NA NA NA NA NA NA NA NA NA
pressure_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pressure_partner_cw NA NA NA NA NA NA NA NA NA NA
pushing_partner_cw:facilitators_partner_cw NA NA NA NA NA NA NA NA NA NA
facilitators_partner_cw:pushing_partner_cw NA NA NA NA NA NA NA NA NA NA
Random Effects
sd(Intercept) 1.44 [1.08, 1.97] 0.31 [0.23, 0.42] 0.33 [0.25, 0.43] 0.61 [0.48, 0.79] 2.49 [1.54, 3.87]
sd(persuasion_self_cw) 0.17 [0.01, 0.51] 0.10 [0.05, 0.16] 0.06 [0.02, 0.10] 0.04 [0.00, 0.11] 0.68 [0.08, 1.39]
sd(persuasion_partner_cw) 0.20 [0.01, 0.54] 0.05 [0.01, 0.11] 0.05 [0.01, 0.10] 0.05 [0.00, 0.12] 0.76 [0.07, 1.83]
sd(pressure_self_cw) 0.54 [0.03, 2.05] 0.08 [0.00, 0.30] 0.07 [0.00, 0.24] 0.07 [0.00, 0.26] 2.41 [0.87, 4.59]
sd(pressure_partner_cw) 0.53 [0.03, 2.08] 0.05 [0.00, 0.20] 0.04 [0.00, 0.13] 0.08 [0.00, 0.28] 1.84 [0.13, 4.57]
sd(pushing_self_cw) 0.61 [0.07, 1.30] 0.07 [0.00, 0.16] 0.08 [0.01, 0.15] 0.09 [0.01, 0.20] 0.62 [0.05, 1.47]
sd(pushing_partner_cw) 0.64 [0.07, 1.47] 0.06 [0.00, 0.15] 0.05 [0.00, 0.11] 0.09 [0.01, 0.21] 0.51 [0.02, 1.72]
sd(barriers_self_cw) 1.27 [0.91, 1.79] 0.20 [0.08, 0.33] 0.14 [0.08, 0.21] 0.33 [0.24, 0.45] 1.52 [0.24, 2.97]
sd(barriers_partner_cw) NA NA NA NA NA NA NA NA NA NA
sd(facilitators_self_cw) NA NA NA NA NA NA NA NA NA NA
sd(facilitators_partner_cw) NA NA NA NA NA NA NA NA NA NA
Additional Parameters
sigma NA NA 0.66 [0.63, 0.69] 0.53 [0.51, 0.55] 0.84 [0.81, 0.87] NA NA

Plot Interaction effect.

  1. Probability of being active (crossing the hurdle)
library(ggplot2)
library(plotly)


p <- conditional_effects(
  pa_sub, 
  dpar = 'hu',
  effects = 'pushing_self_cw:barriers_self_cw',
  re_formula = NA, 
  method = 'posterior_linpred',
  plot = FALSE
)

p2 <- p

p2[[1]]$estimate__ <- 1 - p[[1]]$estimate__
p2[[1]]$lower__ <- 1 - p[[1]]$upper__
p2[[1]]$upper__ <- 1 - p[[1]]$lower__

plots <- plot(p2, theme = theme_minimal(), plot = FALSE) 

plots[[1]] + 
  scale_color_manual(values = c("steelblue", "forestgreen", "coral")) +
  scale_fill_manual(values = c("steelblue", "forestgreen", "coral"))

Test slope of pushing at high levels of barriers

library(tidybayes)
library(dplyr)
library(ggplot2)

plot_slope_by_moderator <- function(
  mod,            
  df,             
  moderator,      
  predictor_par,  
  interaction_par,
  exponentiate = FALSE,   
  n_points = 1000,
  fill_colors = c("Significant" = "steelblue",
                  "Non-significant" = "coral"),
  line_colors = fill_colors,  # Reuse fill colors by default
  vjust_val = -1.5
) {
  
  # Generate a sequence of moderator values
  moderator_seq <- seq(
    from = min(df[[moderator]], na.rm = TRUE),
    to = max(df[[moderator]], na.rm = TRUE),
    length.out = n_points
  )
  
  # Extract posterior draws for the parameters of interest
  library(rlang)
  predictor_sym <- rlang::sym(predictor_par)
  interaction_sym <- rlang::sym(interaction_par)

  post_draws <- mod %>%
    spread_draws(!!predictor_sym, !!interaction_sym)
  
  # For each moderator value, compute the slope for each posterior draw
  slope_list <- lapply(moderator_seq, function(mod_val) {
    tibble(
      moderator_value = mod_val,
      slope = - (post_draws[[predictor_par]] + mod_val * post_draws[[interaction_par]])
    )
  })
  
  # Combine the list into a single data frame
  slope_df <- bind_rows(slope_list)
  
  # Summarize the posterior for each moderator value (using a 95% credible interval)
  slope_summary <- slope_df %>%
    group_by(moderator_value) %>%
    summarize(
      slope_median = median(slope),
      slope_lower  = quantile(slope, probs = 0.025),
      slope_upper  = quantile(slope, probs = 0.975)
    ) %>%
    # Create significance flag: "sig" if CI excludes 0, "ns" otherwise
    mutate(sig_flag = if_else(slope_lower > 0 | slope_upper < 0, "sig", "ns")) %>%
    arrange(moderator_value)
  
  # If exponentiate == TRUE, transform slope columns
  if (exponentiate) {
    slope_summary <- slope_summary %>%
      mutate(
        slope_median_exp = exp(slope_median),
        slope_lower_exp  = exp(slope_lower),
        slope_upper_exp  = exp(slope_upper)
      )
  }
  
  # Identify boundary rows and duplicate them for each category
  slope_summary <- slope_summary %>%
    mutate(
      next_sig_flag = lead(sig_flag),
      is_boundary   = sig_flag != next_sig_flag & !is.na(next_sig_flag)
    )
  
  boundary_rows <- slope_summary %>%
    filter(is_boundary)
  
  boundary_rows_next <- boundary_rows
  boundary_rows_next$sig_flag <- boundary_rows_next$next_sig_flag
  
  slope_summary_extended <- bind_rows(slope_summary, boundary_rows_next)
  
  # Split into "sig" and "ns"
  slope_summary_sig <- slope_summary_extended %>% filter(sig_flag == "sig")
  slope_summary_ns  <- slope_summary_extended %>% filter(sig_flag == "ns")
  
  # Build the base plot:
  #    We'll use either slope_{median, lower, upper} or slope_{median_exp, lower_exp, upper_exp} 
  #    depending on exponentiate.
  if (exponentiate) {
    median_col <- "slope_median_exp"
    lower_col <- "slope_lower_exp"
    upper_col <- "slope_upper_exp"
    y_lab <- "Odds Ratio (Exponentiated Slope)"
    ref_line <- 1  # reference line for ORs is 1
  } else {
    median_col <- "slope_median"
    lower_col <- "slope_lower"
    upper_col <- "slope_upper"
    y_lab <- "Slope (Log-Odds Scale)"
    ref_line <- 0
  }
  
  p <- ggplot() +
    # Non-significant region
    geom_ribbon(
      data = slope_summary_ns,
      aes_string(
        x = "moderator_value",
        ymin = lower_col,
        ymax = upper_col,
        fill = '"Non-significant"'
      ),
      alpha = 0.2
    ) +
    geom_line(
      data = slope_summary_ns,
      aes_string(
        x = "moderator_value",
        y = median_col,
        color = '"Non-significant"'
      ),
      size = 1
    ) +
    # Significant region
    geom_ribbon(
      data = slope_summary_sig,
      aes_string(
        x = "moderator_value",
        ymin = lower_col,
        ymax = upper_col,
        fill = '"Significant"'
      ),
      alpha = 0.2
    ) +
    geom_line(
      data = slope_summary_sig,
      aes_string(
        x = "moderator_value",
        y = median_col,
        color = '"Significant"'
      ),
      size = 1
    ) +
    # Reference line (0 for log-odds, 1 for odds-ratios)
    geom_hline(
      yintercept = ref_line, 
      linetype = "dashed"
    ) +
    # Manual scales for fill & color
    scale_fill_manual(
      values = fill_colors
    ) +
    scale_color_manual(
      values = line_colors
    ) +
    labs(
      x = moderator,
      y = y_lab,
      fill = "Significance",
      color = "Significance"
    ) +
    theme_minimal()
  
  # Add boundary lines (where significance changes) & labels
  p2 <- p +
    geom_vline(
      data = boundary_rows,
      aes(xintercept = moderator_value),
      color = fill_colors["Significant"],
      alpha = 0.35,
      size = 0.7,
      linetype = "dashed"
    ) +
    geom_text(
      data = boundary_rows,
      aes(x = moderator_value, y = -Inf, label = round(moderator_value, 3)),
      vjust = vjust_val,
      size  = 3.7
    )
  
  return(p2)
}


p_log_odds <- plot_slope_by_moderator(
  mod = pa_sub, 
  df = df_double, 
  moderator = "barriers_self_cw", 
  predictor_par = "b_hu_pushing_self_cw", 
  interaction_par = "b_hu_pushing_self_cw:barriers_self_cw",
  exponentiate = FALSE
)

p_log_odds

p_odds_ratio <- plot_slope_by_moderator(
  mod = pa_sub, 
  df = df_double, 
  moderator = "barriers_self_cw", 
  predictor_par = "b_hu_pushing_self_cw", 
  interaction_par = "b_hu_pushing_self_cw:barriers_self_cw",
  exponentiate = TRUE,
  vjust_val = -12,
) + coord_cartesian(ylim = c(1, 18))

p_odds_ratio

# Export
ggsave(
  filename = file.path("Output", "InteractPlot_log_odds.png"), 
  plot = p_log_odds,
  width = 8,
  height = 5,
  dpi = 300,
  bg = 'white'
)

ggsave(
  filename = file.path("Output", "InteractPlot_odds_ratio.png"), 
  plot = p_odds_ratio, 
  width = 8, 
  height = 5, 
  dpi = 300,
  bg = 'white'
)
  1. Expected MVPA when the hurdle was crossed (interaction NOT significant)
p3 <- conditional_effects(
  pa_sub, 
  dpar = 'mu',
  effects = 'pushing_self_cw:barriers_self_cw',
  #re_formula = NULL, 
  plot = FALSE
)

p3[[1]]$estimate__ <- exp(p3[[1]]$estimate__)
p3[[1]]$lower__ <- exp(p3[[1]]$lower__)
p3[[1]]$upper__ <- exp(p3[[1]]$upper__)

plot(p3, ask = FALSE)

  1. Expected physical activity in Minutes (when both components combined)
# Expected physical activity
p4 <- conditional_effects(
  pa_sub, 
  effects = 'pushing_self_cw:barriers_self_cw',
  #re_formula = NULL,
  plot = FALSE
)

plot(p4, ask = FALSE)

report::report_system()

Analyses were conducted using the R Statistical language (version 4.4.2; R Core Team, 2024) on Windows 11 x64 (build 26100)

report::report_packages()
  • rmarkdown (version 2.29; Allaire J et al., 2024)
  • beepr (version 2.0; Bååth R, 2024)
  • R.methodsS3 (version 1.8.2; Bengtsson H, 2003)
  • R.oo (version 1.27.0; Bengtsson H, 2003)
  • R.utils (version 2.12.3; Bengtsson H, 2023)
  • brms (version 2.22.0; Bürkner P, 2017)
  • posterior (version 1.6.0; Bürkner P et al., 2024)
  • extrafont (version 0.19; Chang W, 2023)
  • digest (version 0.6.37; Eddelbuettel D, 2024)
  • Rcpp (version 1.0.13.1; Eddelbuettel D et al., 2024)
  • bayesplot (version 1.11.1; Gabry J, Mahr T, 2024)
  • lubridate (version 1.9.3; Grolemund G, Wickham H, 2011)
  • DHARMa (version 0.4.7; Hartig F, 2024)
  • rlang (version 1.1.4; Henry L, Wickham H, 2024)
  • tidybayes (version 3.0.7; Kay M, 2024)
  • wbCorr (version 0.1.22; Küng P, 2023)
  • see (version 0.9.0; Lüdecke D et al., 2021)
  • tibble (version 3.2.1; Müller K, Wickham H, 2023)
  • patchwork (version 1.3.0; Pedersen T, 2024)
  • R (version 4.4.2; R Core Team, 2024)
  • openxlsx (version 4.2.7.1; Schauberger P, Walker A, 2024)
  • plotly (version 4.10.4; Sievert C, 2020)
  • ggplot2 (version 3.5.1; Wickham H, 2016)
  • forcats (version 1.0.0; Wickham H, 2023)
  • stringr (version 1.5.1; Wickham H, 2023)
  • rvest (version 1.0.4; Wickham H, 2024)
  • tidyverse (version 2.0.0; Wickham H et al., 2019)
  • readxl (version 1.4.3; Wickham H, Bryan J, 2023)
  • dplyr (version 1.1.4; Wickham H et al., 2023)
  • purrr (version 1.0.2; Wickham H, Henry L, 2023)
  • readr (version 2.1.5; Wickham H et al., 2024)
  • xml2 (version 1.3.6; Wickham H et al., 2023)
  • tidyr (version 1.3.1; Wickham H et al., 2024)
  • ggridges (version 0.5.6; Wilke C, 2024)
  • knitr (version 1.49; Xie Y, 2024)
  • kableExtra (version 1.4.0; Zhu H, 2024)
report::cite_packages()